Graphical User Interfaces (GUI - pronounced "gooey") are the familiar ways that we interact with computers. Before Xerox invented the GUI in the 1970s, command lines provided the only interfaces to computers. Since the mid-eighties, GUIs have become the only interfaces to computers that most people know.
There are at least two ways to implement a GUI:
The first approach was that taken by Apple in its earliest Macintosh computers, and is that taken in Windows NT/2000/etcetera. The latter approach is that adopted by all versions of Unix, and OS X. It is interesting to note that Microsoft has moved away from the second approach toward the first, while Macintosh started with the first approach, but now runs its GUI over a Unix operating system. The reason Microsoft abandoned the second approach was that it was dependent on DOS, the technically flawed Microsoft home operating system of the eighties. The reason Apple has moved toward the second approach is that it is technically superior.
The problem with the first approach is that it requires graphics, with all of the requirements on connection, hardware, and peripherals that it entails. In other words, if the operating system and graphics are all of a piece, then if you have a problem with the graphics hardware or software configuration, you cannot even get to the operating system to diagnose it. This makes it difficult to troubleshoot the operating system in case of hardware failure, and it makes it difficult or impossible to run a session on a remote computer. For this reason, Windows has historically been a single-user operating system, and remains so today.
We should note in passing that there are a few ways to run Windows sessions remotely. Since Windows NT 4.0 it has been possible to purchase a "terminal server" version of the operating system, that can provide a session running on one Windows machine to a screen on another Windows machine. there are companies that make software to adapt this session to other operating systems, including various flavors of Unix. There is free software called VNC that can show the session running on one machine to several other machines simultaneously.Since XP, Windows has permitted so-called remote desktop services, which share a screen with one other computer. Note that this approach is seriously flawed in that when you use remote desktop, you are monopolizing two computers to run software on just one. By contrast, on modern operating systems the idea is to permit many people to run software on a single machine.
In contrast, when the GUI runs separately from the operating system, then it is possible to send the graphical output anywhere, or to run multiple sessions as easily as one, or even to run individual graphical applications on remote machines.
This is the system adopted in X-windows, the GUI for Unix. X-windows is based on the idea of an X-server, a program that runs on any operating system, which is responsible for transmitting commands to and from applications in the operating system. The X-server, together with another program called a window manager (and sometimes a desktop manager), handles all keystroke and mouse input and decides where to send it, and handles all aspects of the display, including window size and position, fonts, and whether a window is active or not. The X-server interacts with the user and also with an X-client, which is some application whose output appears inside a window. Thus, in changing the shape of a window, or clicking the "X" button to close it. or clicking the button at the upper left of the window, you are interacting with the X-server/window manager. In clicking the inside of the window or typing inside the window, your commands are sent to the client.
Examples of X-windows applications include Xdvi, Firefox, Gimp (a photoshop-type program), and Libre Office (an Office package). In addition, we will learn about Matlab and Maple in this course.
X-windows can be used across a network easily. All that is required is
X-server software on the local machine, and commands to tell the local
and remote machines to work together.
The best way to do this is to log in to the
remote machine using the -X switch on ssh: e.g.
ssh -X firstname.lastname@example.org
In a pinch, one can do some more complicated things that too often don't work. For the record, they go like this. After starting the X-server on the local machine, you usually need to execute two commands. The first tells the local computer to accept output from the remote machine, and the second tells the remote machine where to send its graphical output.
For example, suppose that "local" is the name of the machine in front of you, and "remote" is the name of a computer in the basement. First, you make sure that local is running an X-server. If it is a Unix machine, it surely already is. If it is a Windows machine, then you might have to start a program called X-win32, or something similar.
Next, you log onto remote using a program called ssh. On a Unix machine this looks like
On a Windows machine, you run a program called ssh.exe or ttssh.exe or putty.exe.
Once logged into remote, you must tell it where to send its X-windows output. The command in bash is
setenv DISPLAY local:0
We emphasize that you type this command on the remote machine, and that you must replace the name "local" by the name of the machine in front of you.
Finally, you must tell local to accept the X-windows output from remote. If local is a Unix machine, you type
If local is a Windows machine, you must modify the "xhost" settings (e.g. using a program called X-Util32) to include remote. After all this, you may run any X-windows program on the remote machine and see the output on the local machine.
To summarize, in order to run graphical applications from a distant Unix machine you should perform some or all of the following steps.
Finally, we reiterate that when you use ssh with the -X switch as described above, your X-windows settings should be preserved. In particular, you should not have to give the "setenv DISPLAY" command above if you use ssh from one Unix machine to another - try it to find out.