Error: Can't open display: - linux

I am working my way through 'The linux command line' (http://linuxcommand.org/tlcl.php) . Since I don't have a local linux environment and I have to work in windows , I am telnetting into an Ubuntu 14.4 LTS instance on EC2 , with putty. On page 114 , when I run the xlogo command I get:
ubuntu#ip-172-31-22-65:~$ xlogo
Error: Can't open display:
How can I get this working?

xlogo will try to access the current Xserver to display a logo. If you're telneting to a box, you will not have an X server available, which is what that "can't open display" message is saying. It's trying to look at your DISPLAY environment variable to use that to show the logo on, but you don't have a display to use, and thus have nothing in your DISPLAY variable.
You will need access to an X server somewhere to do that step. One option would be to install cygwin on your Windows machine. Then you wouldn't need the remote linux box for most steps I imagine, because you could just use your local cygwin environment. Even if you want to use the remote box still, if you use cygwin and launch an xterm with it, you could ssh -X <host> and that will export your DISPLAY to that remote machine so it can display back on your windows machine.

As I mentioned in the comment under Eric Renouf answer, I am working thru the same book. That part of the book have some testing of creating users, groups, shifting users, group permissions etc. I found that I needed to log the same user out quite some times. The last time logging that user out, I got a message saying xlogo is terminatet, like it was hanging on that user?
After everyone was logged out, I logged in as sudo and everything worked again.

Related

Pyautogui on RDP

I am using pyautogui in Windows 10 with Python 3, in a virtual machine accessed by remote desktop.
Unfortunately, the program stops execution when I close remote connection, giving "OSError: screen grab failed".
I've searched for a solution online, but the only workaround that I've found is from this link
Use a remote desktop client that allows you to keep outputting the display, even if you minimise the window/close your PC. I used terminals (https://terminals.codeplex.com/ - not affiliated with them at all just recommending as it solved this issue for me).You can set this up to persist the display, and your code should then run fine.
The problem is that I can't find a setting for persisting display. I've also found this:
pyautogui._pyautogui_x11._display = Xlib.display.Display(
os.environ['DISPLAY']
)
... but it doesn't seems to work either (gives me errors...).
Do you have some workaround to do the trick?
Based on an answer from here:
when you disconnect from RDP, Windows lock the computer and does not render the screen any more so any automation apps which needs GUI fails to work.
To disconnect from RDP without losing the screen you can disconnect using following commands as administrator (its better to make a bat file and run that file as administrator when you need to disconnect from RDP):
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console )
I have resolved using TightVNC instead of remote desktop and detaching mouse cursor.

Any git repo viewer that works over SSH?

so I have a folder of Git repositories on a Linux(Ubuntu) box that I can only access via commandline SSH. I mainly work on Windows and I want to find a way to look at the list of repositories on Windows via some sort of GUI, I tried using Gitlist,http://gitlist.org/, but I'm not sure how to access the localhost of the Ubuntu machine from my Windows machine.
Any help is appreciated.
Emacs can display git logs with their graph structure in text mode. Just start emacs, type C-xvd, type in the path and hit Enter. In the status buffer, just press l to view the log.
BTW, if you know no Emacs: use C-xC-c to end Emacs.
A generic solution which also can be used for other programs than git viewers might be a X-Server for Windows like MobaXterm.
With that installed you can start any X program from the ssh shell if X display forwarding is active. The X program is then displayed on your Windows screen.

Cannot connect with FreeNX to Ubuntu ec2 instance

I have recently spun up a new Ubuntu 12.04 instance in AWS. I had no issues connecting to and opening an SSH terminal to the server. Having connected to the instance, I was able to install the Ubuntu desktop and FreeNX without any problem, as well as enabling password authentication on the server instance.
I downloaded and installed the NX Client for Windows on a PC running Windows 8. After entering the user credentials I can connect to and authenticate into the server. I'm brand new to the Linux world, but at this point everything was going so smoothly I was about ready to throw my Windows licenses to the dogs - good thing I held off on that.
"Problem: At the client, the !M logo window appears, but after a few seconds that window just closes, even without showing any error message."
That problem statement is in quotes because it's precisely the issue described in FreeNX Ubuntu Community support documentation https://help.ubuntu.com/community/FreeNX#Troubleshooting.
So naturally I follow the solution in the guide:
"Solution: The issue is due custom VNC configuration. In the server, access your home directory and run these commands,"
sudo rm .Xauthority*
touch .Xauthority
chmod 600 .Xauthority
Unfortunately, this did absolutely nothing to resolve the issue. The problem would be easier to diagnose if I had an error message, but reference the Problem statement, there is no error message to be had. Several hours of googling yielded nothing, so wondering if anyone here has encountered this problem in the past, and if so, they would be willing to help.
Thanks!

Linux - Make Application started in a terminal launch on a different display

I have inherited an application that is launched at login time from my server's .bashrc. The application starts two gnome-terminals. If I am logged in with a gnome desktop, it works great. Two terminals open on the desktop.
Sometimes I kill the application and must restart it. Works great if I launch it by hand from a terminal on the desktop (causing me to have 3 terminals open).
However, if I telnet into the machine where the application is installed, as .bashrc executes I get all sorts of "cannot open display" errors.
Well, of course I can't, I'm not logged in from a gui interface, But a desktop IS running on my server and is logged in using the same ID! Why not put the terminals there?
So how do I say, in bash, "start this application and send its output to 1) the display where you are now, or, 2) the one currently up on the server?" (I assume that found by looking at the env var display?)
Ubuntu 10.04 64 bits. I telnet to the server to start the vncserver so I can access the aforementioned desktop.
Thanks,
It depends on the application exactly, but generally you simply export the DISPLAY environment variable and the application should start on the specified display.
eg:
export DISPLAY=localhost:0.1
xterm &
Some applications would also (or alternatively) take a --display command line argument - check into the specific options available for the applications you're using.

ssh and window ids

I have a project to do in school which is baffeling me... I am SSHing into a Solaris computer in the computer lab from my own Debian box via
ssh -Y name#***.cs.<school>
I can get in just fine, and the X11 seems to be working also. However, this peticular project requires us to find the window id of a netscape window via xwininfo and use this information in the following command
netscape -id 0xa00029 -remote 'openFile(/path/to/html/file)'
Now, if this netscape is the only window I have open (other than xterm), the preceding command works just fine. However, if I have any other iceweasel windows open (regardless of the order in which I opened netscape/iceweasel) the command will forward to my iceweasel despite the facts that I'm running the command in my SSH session and the two windows have very different window ids.
All of this eventually has to go into a C program, but I can't even get it to work reliably manually!
Any ideas?
P.S. I just saw this that may help. When I SSHed via Cygwin/X using the same command, I get this error
Warning: No xauth data; using fake authentication data for X11 forwarding.
Not sure if this is important as I can still use X11 (aparently) perfectly.
Thanks.
P.P.S the -id switch is documented in the netscape man pages:
-id window-id
Identifies an X window to receive -remote commands. If
you do not specify a window, the first window found is
used.
When you use ssh -Y, you're requesting that remote clients be forwarded to your local X server, with full permissions. The Netscape/Mozilla/Firefox/Iceweasel/Etc. remote protocol runs through the X server, so it'll be forwarded too.
http://www.mozilla.org/unix/remote.html documents the protocol, and mentions nothing about -id. Nor does a very quick look at the source (e.g., http://mxr.mozilla.org/seamonkey/source/widget/src/xremoteclient/XRemoteClient.cpp#202) look promising for there being an -id option.
I sat down to an actual machine to perform the same tests, and they all fail there too... I would open 2 netscape windows and try to direct the command to one at a time. The most recently opened one would work properly, but any command directed to the other one would be forwarded to the same window, so at this point I am convinced that the problem lies in the command being not properly implemented and/or everything on that system being really, really old.
if I have any other iceweasel windows
open (regardless of the order in which
I opened netscape/iceweasel) the
command will forward to my iceweasel
despite the facts that I'm running the
command in my SSH session and the two
windows have very different window ids
Iceweasel is coded that way. It tries to have only a single process run for all open windows for that user.
Use the -no-remote command line option to avoid it. See http://kb.mozillazine.org/Command_line_arguments

Resources