Table of Contents

What is the DISPLAY environment variable? X11

About

The magic word in the X window system is DISPLAY.

The DISPLAY environment variable:

The remote server knows where it have to redirect the X network traffic via the definition of the DISPLAY environment variable.

The X display server install itself normally as display number 0 on your local machine.

A display consists (simplified) of:

A display is managed by a server program, known as an X server. The server serves displaying capabilities to other programs that connect to it.

SSH

The SSH protocol has the ability to securely forward X Window System applications over an encrypted SSH connection.

You can then run an application on the SSH server machine and have it put its windows up on your local machine without sending any X network traffic in the clear.

In Putty, the “X display location” box reads localhost:0. The host is localhost because SSH forward it back to your computer thanks to X11 Forwarding.

Note:

Syntax: The environment variable

Value

The value of the display environment variable is:

hostname:D.S

where:

Example of values

localhost:4
gerardnico.com:0
:0.0

Management: How to set the DISPLAY variable

With Putty

Generally you are using the putty terminal to connect.

Putty X Forwarding

More See Cygwin and Putty

In the console

Setting the DISPLAY variable, depend of your shell

export DISPLAY=localhost:0.0      
setenv DISPLAY localhost:0.0

In this example, local_host is the host name or IP address of the local computer that you want to use to display for instance an installation screen such as Oracle Universal Installer.

For a sudo session

In a sudo session (you log on to a host as a non-root user and then create a sudo session to perform administrative functions)

If you do this remotely, multiple credentials may be used. If you simply try sudo xterm, it won’t work, because the xterm is running as root, but root doesn’t have the proper X11 authentication to connect to the X server machine.

To run an X11-based tool, you need to set the proper X credentials in the sudo session by fixing the xauth profile for root.

So copy the following in your root .bash_profile, substituting your logon username for adminuser:

su - adminuser -c 'xauth list' |\
 grep `echo $DISPLAY |\
 cut -d ':' -f 2 |\
 cut -d '.' -f 1 |\
 sed -e s/^/:/` |\
 xargs -n 3 xauth add