The most important environment variable for
X Window System clients is DISPLAY. When a user logs in at an X terminal, the
DISPLAY environment variable in each xterm
window is set to her X terminal's hostname followed by :0.0
.
ruby:joan % echo $DISPLAY
ncd15.ora.com:0.0
When the same user logs in at the console of the workstation named
sapphire that's running X, the DISPLAY environment
variable is defined as just :0.0
:[1]
sapphire:joan % echo $DISPLAY
:0.0
The DISPLAY environment variable is used by all X clients to determine what X server to display on. Since any X client can connect to any X server that allows it, all X clients need to know what display to connect to upon startup. If DISPLAY is not properly set, the client cannot execute:
sapphire:joan %setenv DISPLAY foo:0
sapphire:joan %xterm
xterm Xt error: Can't open display:
You can override the value of DISPLAY by using the -display
command-line option. For example:
sapphire:joan % xterm -display sapphire:0.0 &
The first part of the display name (up to and including the colon) identifies
the type of connection to use and the host that the server is running on. The
second part (in most cases, the string 0.0
)
identifies
a server number
and an optional screen number. In most cases, the server
and screen numbers will both be 0. You can omit the screen number name if the
default (screen 0) is correct.
Note that like all other environment variables set in your shell environment, the DISPLAY environment variable will propagate (Section 35.3) to all processes you start from that shell.
When you run clients from remote machines, some additional problems with the DISPLAY environment variable need to be addressed. See Section 6.10 for more information on running remote clients.