How to export your X Display

It is possible to use your computer at home or in the labs to login to the CS machines and use cool graphical tools like xclock. The system that makes this possible is the X Windows System (X), it is the basis for all GUI application on the CS machines. One of the design ideas behind X is the idea of remote displays, in much the same way a standard telnet login works. From another computer you connect to your sever over a network login and do all kinds of neat command line things remotely. X is the method that allows you to login to the server and use neat graphical things remotely.

This document describes the basics to using this remote display function of X. It assumes that you have access to a fast network (10Base-T, or maybe ISDN speeds) and you have access to a machine that runs X applications, our CS machines do this. The software needed on your own computer is called an X server, it allows the connections from the X clients to display application on your screen. There are several X server software packages available freely for several operating systems. For Linux or other Intel architecture UNIXes Xfree86 is common, for Windows there is Micro-X, and for Macs there is MI/X. You should follow the documentation that came with your X server for installation.

Next lets get some basics of how this all really works. On your computer your are running an X server that among other things watches a port for incoming connections. Also the X server sets up a view window where all the X application. windows will be displayed, this is called a root window. It is possible to have more than one root window. The X application you want to run on a remote computer has been compiled with libraries that allow it to communicate with the X server and tell it what to display in the root window. These applications are called X clients. When an X client is run it looks for an X server port to connect to and start issuing commands to display information. When an X server gets a connection on its port there is a small amount of security that the client has to be checked on. Usually this check is to see if the clients host is on a list of allowed client hosts. Once the check and connection is established the X server reads commands from the X client and starts building a window in the root window for the client. The servers job is not only to display graphics it also sends mouse clicks and key presses to the connected clients, in this way you have all the functionality you need to make a working GUI.

In the following paragraphs I will give several examples of how to use X using UNIX based X servers such as Xfree86. For other OSes refer to the user manual of your X server to find how to do similar things. First lets load an X server under Linux and see some of the details inside (further details of how to get this far are at Xfree86):

$ startx

This starts the server and by default starts a single xterm. An xterm is just a simple X client to display text in, usually a login shell. Assuming you are running bash you can look at your environment variables (EV) by typing "set". Environment variables store useful information for programs defaults or system state. If you look at your EV you will see a variable called "DISPLAY" this variable stores the address for X clients to connect to. These addresses are in the form:


A typical example would be:

I said earlier that it is possible to have more than one X server running at a time. In this case the displayname would be something like


depending on how its done.

When the X clients start the look at the DISPLAY EV to see where to connect to by default. One way to do remote displaying would be to set this EV to a remote X server.

$ export

Then you can run your cool X application and its display will be on

$ xclock

Another way to do remote display is by a command line option that all X applications have: "-display [displayname]". To run your cool X application:

$ xclock -display

This does the exact same as before.

The previous demonstrations rely on whether your X server is allowing connections from remote hosts. The following command allows connections from all hosts (run on machine that the X server is running on (

$ xhost +

To allow connections from single hosts at a time:

$ xhost

ssh is a neat remote login tool that in addition to having secure encrypted transmissions auto forwards your X DISPLAY EV if your are running it under an X Server. ssh allows a easy, no hassle, way to do all of the stuff we have discussed so far. The ssh documentation has more detailed information on how to get this working.

Tips for other non-UNIX users

Because most other operating system don't have X Server as one of their basic packages using X can be quite a bit different than under UNIX. Usually all the non-UNIX X Servers do is create a root window and start watching ports. They usually don't start a Xterm to allow you to do everything you need by that. Often there are dialog boxes or menus that set the access lists and show the DISPLAY name so that you can use a external telnet program to connect to your client machine and set the variables by hand there. Your X Server software should give an example of how you might export your display using their tools.

Some Links on the topic:

Jamie Marconi
Last modified: Fri Mar 21 21:29:28 PST