Using the X Windows System

The X Windows system is a windowing graphical user interface that is almost, but not comletely, entirely unlike Microsoft Windows and the Macintosh. The main feature of this system is that the program that you run to do useful work, such as the XTerm terminal emulator, and the user interface (window, mouse, keyboard) can be on different machines. In fact, the program and its user interface can be running on different continents, with all communications going over the Internet!

Terminology

The most confusing thing about X Windows is the terminology. After mastering the terminology, it gets better (but only very slightly).

The X Windows Server
The X "server" is the machine that is responsible for managing the screen, mouse and keyboard. It's called a server because it "serves" graphics. When you use eXceed on your laptop to bring up a window on cerebus or phage, the laptop is acting as the server. When you use X Windows, you are always sitting in front of the server.
The X Windows Client
The X client is the machine that runs the programs that use the X Windows server. This is where the real work gets done. A typical example is when you are using the XTerm terminal emulator to run a Unix shell. The xterm program and tcsh are executing on the client machine. The xterm graphical user interface (its window, scrollbar, and so forth), are displayed on the server.
The Display
Just to make things confusing, X Windows allows a server to have more than one display. This is sometimes used to create multiple virtual desktops that you switch back and forth between, and sometimes to support several physical monitors. Displays have funny names like 0.0, 1.0, and 0.3. Almost always you'll use "0.0", corresponding to the main display for the server.

Setting the X Windows Display

When you launch an X Windows program, it needs to know what server and display its windows on. This is done using an environment variable DISPLAY. If you log into a Unix machine the ordinary way using a graphical login window, or if you use ssh to log into a remote machine, then DISPLAY will already be set up for you. Just give the command to start up a windowing program and it will pop up its windows and run.

However, if you log in to a remote machine using telnet and try to run an X-Windows command, you will get an error message. You will have to set up DISPLAY manually. You can specify DISPLAY in either of two ways:

1. Set the DISPLAY environment variable.
DISPLAY contains the name of the server and display, separated by a colon (:). For example:
      pc110.cshl.org:0.0
The display is the primary monitor on a computer named pc110.cshl.org.

You can change the display using setenv. After this, all programs you run will display on the indicated machine.

      (~) 54% setenv DISPLAY pc220.cshl.org:0.0
      (~) 55% xterm &

2. Pass the -display command-line option to the client program when launching it.
The -display option takes a display name in the same format as DISPLAY. For example:
      (~) 56% xterm -display pc220.cshl.org:0.0 &

X Windows Security

Without any security provisions, the X Windows system would allow you to pop up a graphical window on anyone's monitor, anywhere in the world. To avoid this, X servers provide access control based on the client's hostname and IP address.

xhost

You can manipulate the access control list with the xhost program. Without any command-line arguments, xhost prints out the list of hosts that are allowed to connect. You can add a host to the list with xhost +hostname, or remove a host from the list with xhost -hostname. In a pinch, give the command xhost + which turns off all access control. Don't forget to run xhost - to turn access control on again when you are through.

X Windows Tricks

There are several tricks to using X Windows programs.

To Copy Text from One Window to Another

  1. Select the text by clicking and dragging with the left mouse button.
  2. Without clicking again, go to the target window and press the middle mouse button to paste in the selected text. If you don't have a middle mouse button, then press the left and right mouse buttons simultaneously.

Some X Windows programs have a civilized Edit menu with Cut, Copy and Paste commands. Don't count on it.

To Use the XTerm Scrollbar

Some older X Windows programs use a funky scrollbar that looks like a gray rectangle. To use it, click and drag in the scrollbar with the middle mouse button (or left+right if you don't have one). To scroll upward one screen click the left mouse button anywhere in the scrollbar. To scroll downward one screen, click the right mouse button.


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Thu Oct 9 20:17:47 EDT 2003