I have (in a cursory way) described how XWindows works already here but you might profit from me expanding on that a bit:
XWindows is a complete networked system for working with graphically oriented programs. In fact it is more a client/server-oriented protocol (like, i.e. ftp
) rather than a piece of software.
On one hand you have some graphical display - a graphics adapter attached to a system and a screen capable of graphical output (for the sake of simplicity we will voluntarily leave out multi-screen displays and other complicated things for now). This is called an X-server, because it provides certain capabilities whcih can be used by clients. In fact an X-server is a piece of software which manages this piece of hardware. Think of it as a networked graphics driver.
On the other hand there are programs being able to use the capabilities such an X-server provides: these are called X-clients. Notice that the X-server usually runs on the client machine (the one you sit in front of) and the X-client runs on the server system (i.e. a machine in the data centre). This can be a bit confusing at first, but actually from the role the various software pieces are playing - here a pice that provides some service, there a piece that makes use of this service - it makes perfect sense.
In between these two programs there needs to be a network connection (except for the special case where they are running on the same system) and in fact XWindows has its own transport protocol: X-protocol (now, who'd have thought this is its name?). X-protocol per default uses port 6000.
This is what you need the DISPLAY-variable for: it tells the X-client (in your case: xclock
which server to use to display itself. There could be more than one server in the network. The DISPLAY-variable has the following format:
<FQDN>:<Display-Nr>.< Screen-Nr>
i.e.: myclient.somecompany.com:0.0 means: use the X-server on myclient.somecompany.com for output and display it on the first screen (screen 0) of the first display (display 0). A system could have several displays attached and each display could consist of several screens, hence the numbers. So you set the DISPLAY-variable in the environment of the X-client process first, then start the X-client. The X-server has to run already for this.
Now, an X-server might not want to allow every client to use it, so there is some sort of access control. This is what the program xhost
is for. I suggest to carefully read its man-page, but for test purposes we can simply switch off any access control with:
# xhost +
Nota bene: you do this on the X-servers side, because having access control only makes sense on the system where the X-server runs. Now (and given that no firewall interferes with port 6000) it should work.
I hope this helps.
bakunin