Understanding linux DISPLAY variable

20.5k Views Asked by At

I am new to Linux and I had to set DISPLAY variable for running a Java application. Somehow I managed to do that, and I understand that display can be set using

<host>:<display>[.<screen>]

but what I am doing is <host>:1001.

Now, this 1001 is 1001th display of this Linux? Are this many display possible in a machine or my understanding is wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

The DISPLAY variable is used by X11 to identify your display (and keyboard and mouse). Usually it'll be :0 on a desktop PC, referring to the primary monitor, etc.

If you're using SSH with X forwarding (ssh -X otherhost), then it'll be set to something like localhost:10.0. This tells X applications to send their output, and receive their input from the TCP port 127.0.0.1:6010, which SSH will forward back to your original host.

And, yes, back in the day, when "thin client" computing meant an X terminal, it was common to have several hundred displays connected to the same host.

0
On

The DISPLAY values are usually like :0, :0.0, etc. when running under the X Window server on the same host. Big numbers like in :1001 are typical for SSH passed X connection. The numbers are really summand to 6000 to get TCP port number; local ones start with 6000 and SSH passed ones could start with 7000. (This augment is different in different systems, e.g. 10 or 100 are also possible.)

As soon as these values are assigned dynamically, you should get the value for DISPLAY from an existing connection environment, provided that proper authorization token is also available (e.g. in ~/.Xauthority).