How can I specify a display?

X11

X11 Problem Overview


When I run some programs over SSH, such as firefox &, I get an error

Error: no display specified 

I would like to open many displays, still showing the stdout of each program.

Initial Question: How can I specify the display to get a many-displayed program?

Pablo Santa Cruz gives me the following code as a solution. I do not understand it.

$ export DISPLAY=yourmachine.yourdomain.com:0.0

$ firefox &

What are yourmachine and yourdomain.com in the command?

X11 Solutions


Solution 1 - X11

The way that X works is the same as the way any network program works. You have a server of some description (in this case, the X display server) which runs on a specific machine, and you have X clients (like firefox) that try to connect to that server to get their information displayed.

Often (on "home" machines), the client and server run on the same box and there's only one server, but X is powerful enough that this doesn't need to happen. It was built with the server/client separation built in from the start.

This allows you to do such wondrous things such as log on to your box (in text mode) halfway around the planet, tell it that the display server is the box you're currently on and, voila, the windows suddenly start appearing locally.

In order for a client to interact with a user, it needs to know how to find the server. There are a number of ways to do this. Many clients allow the -display or --displayoption to specify it:

xeyes -display paxbox1.paxco.com:0.0

Many will use the DISPLAY environment variable if a display isn't specifically given. You can set this variable like any other:

DISPLAY=paxbox1.paxco.com:0.0; export DISPLAY # in .profile
export DISPLAY=paxbox1.paxco.com:0.0 # in your shell
DISPLAY=paxbox1.paxco.com:0.0 firefox & # for that command (shell permitting)

The first part of the DISPLAY variable is just the address of the display server machine. It follows the same rule as any other IP address; it can be a resolvable DNS name (including localhost) or a specific IP address (such as 192.168.10.55).

The second part is X-specific. It gives the X "display" (X server) number and screen number to use. The first (display number) generally refers to a group of devices containing one or more screens but with a single keyboard and mouse (i.e., one input stream). The screen number generally gives the specific screen within that group.

An example would be:

+----------------------------------------+
|paxbox1.paxco.com|                      |
+-----------------+                      |
|                                        |
|  +----------+----+  +----------+----+  |
|  |Display :0|    |  |Display :1|    |  |
|  +----------+    |  +----------+    |  |
|  |               |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.0| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.1| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.2| |  | |Screen :1.0| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.3| |  | |Screen :1.1| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | | Keyboard  | |  | |  Keyboard | |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |   Mouse   | |  | |   Mouse   | |  |
|  | +-----------+ |  | +-----------+ |  |
|  +---------------+  +---------------+  |
|                                        |
+----------------------------------------+

Here you have a single machine (paxbox1.paxco.com) with two display servers. The first has four screens and the second has two. The possibilities are then:

DISPLAY=paxbox1.paxco.com:0.0
DISPLAY=paxbox1.paxco.com:0.1
DISPLAY=paxbox1.paxco.com:0.2
DISPLAY=paxbox1.paxco.com:0.3
DISPLAY=paxbox1.paxco.com:1.0
DISPLAY=paxbox1.paxco.com:1.1

depending on where you want your actual windows to appear and which input devices you want to use.

Solution 2 - X11

$ export DISPLAY=yourmachine.yourdomain.com:0.0
$ firefox &

Solution 3 - X11

When you are connecting to another machine over SSH, you can enable X-Forwarding in SSH, so that X windows are forwarded encrypted through the SSH tunnel back to your machine. You can enable X forwarding by appending -X to the ssh command line or setting ForwardX11 yes in your SSH config file.

To check if the X-Forwarding was set up successfully (the server might not allow it), just try if echo $DISPLAY outputs something like localhost:10.0.

Solution 4 - X11

Try

export DISPLAY=localhost:0.0

Solution 5 - X11

login to your server via

ssh -X root@yourIP

edit /etc/ssh/sshd_config file, and add this line to it.

X11UseLocalhost no

Restart sshd. for CentOS (check your distribution)

/sbin/service sshd restart

check your DISPLAY

echo $DISPLAY

you should see this

yourIP:10.0

Enjoy

firefox

for more info

Solution 6 - X11

Please do NOT try to set $DISPLAY manually when connecting over SSH.
If you connect via SSH -X and $DISPLAY stays empty, this usually means that no encrypted channel could be established.

Most likely you are missing the package xauth or xorg-x11-xauth. Try to install it on the remote machine using:

sudo apt-get install xauth

or

sudo apt-get install xorg-x11-xauth

After that end and restart your SSH connection. Don't forget to use SSH -X so that X Window output is forwarded to your local machine.

Now try echo $DISPLAYagain to see if $DISPLAY has been set automatically by the SSH demon. It should show you a line with an IP address and a port.

Solution 7 - X11

I ran into a similar issue, so maybe this answer will help someone.

The reason for the Error: no display specified error is that Firefox is being launched, but there is no X server (GUI) running on the remote host. You can use X11 forwarding to run Firefox on the remote host, but display it on your local host. On Mac OS X, you will need to download XQuartz in order to use X11 forwarding. Without it, you won't have a $DISPLAY variable set, so if you try and echo $DISPLAY, it will be blank.

Solution 8 - X11

Try installing the xorg-x11-xauth package.

Solution 9 - X11

I faced similar problem today. So, here's a simple solution: While doing SSH to the machine, just add Ctrl - Y.

ssh user@ip_address -Y

After login, type firefox &. And you are good to go.

Solution 10 - X11

Even i faced the same in CentOS 6.8.

yum reinstall xorg*

End your current session and open another session in tool like mobiXterm. Make sure session has X11 forwarding enabled in the tool.

Solution 11 - X11

I through vnc to understand the X11 more. To specify the display to get a many-displayed program, export DISPLAY=IP:DisplayNum.ScreenNum

For example,

vncserver :2
vncserver -list
echo '$DISPLAY'=$DISPLAY 
export DISPLAY=:2  # export DISPLAY=IP:DisplayNum or export DISPLAY=:DisplayNum for localhost; So that can vnc connect and see the vnc desktop :2 if $DISPLAY is not :2.
echo '$DISPLAY'=$DISPLAY

Solution 12 - X11

I'm using xming server before typing firefox use the following command export DISPLAY=0:0

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLéo Léopold Hertz 준영View Question on Stackoverflow
Solution 1 - X11paxdiabloView Answer on Stackoverflow
Solution 2 - X11Pablo Santa CruzView Answer on Stackoverflow
Solution 3 - X11TobiXView Answer on Stackoverflow
Solution 4 - X11sreenathView Answer on Stackoverflow
Solution 5 - X11Ammar BozorgvarView Answer on Stackoverflow
Solution 6 - X11JpsyView Answer on Stackoverflow
Solution 7 - X11AndrewView Answer on Stackoverflow
Solution 8 - X11thegriglatView Answer on Stackoverflow
Solution 9 - X11Nandita ShuklaView Answer on Stackoverflow
Solution 10 - X11Srihari KaranthView Answer on Stackoverflow
Solution 11 - X11YangView Answer on Stackoverflow
Solution 12 - X11amanpreet singhView Answer on Stackoverflow