X Display Tips
This section deals with some X Window System tips for novice X users.
Tip #1: Adding Hosts to the Access Control List
Suppose you're in an X session and you want to start an X program as root. The message you get will be something like the following:
Error: Can't open display
This is because the restrictions made by X allow only the user who started X to start X-based applications. In this case, you should enable the host who will be starting the application by using the command xhost. To enable a host to start X applications on the server, use the following command:
bash$xhost + hostname
The previous command adds the hostname of the host who's allowed to connect to the X server. To allow users connecting from the localhost, use the following command:
bash$xhost + localhost
Users connecting from the localhost will be able to start X programs if they exported the correct DISPLAY environment variable.
Tip #2: Exporting the DISPLAY Environment Variable
After you have added the localhost to the control access list, the root user must export the correct DISPLAY environment variable to connect to the X server. This can be done as follows:
bash#export DISPLAY=:0
Tip #3: Starting X Programs on Other Servers and Exporting the DISPLAY Variable to Your X Server
Let's suppose you want to access some X programs on another machine and want to see them on your X server. If your IP is 192.186.186.5 and the machine from which you want to start the program is 192.186.186.6, you can do the following:
-
Log in to the 192.186.186.6 server using telnet.
-
On your machine, allow the 192.186.186.6 to connect to your X server by issuing the command xhost + 192.186.186.6 in another xterm.
-
On the telnet window, issue the command export DISPLAY= 192.186.186.5:0.
-
Start the program, which will show up on your X Window System.