Xwindows

From UCT EE Wiki
Jump to navigation Jump to search

Overview of X Windows[edit]

The X Window System, or X11, is a windowing system used for Linux and Unix operating systems. X provides the basic infrastructure for a GUI environment. A useful aspect of this is that you can export the display from your Linux shell login to a different display on the PC you are using or to a desktop on a remote computer. Or even a virtual desktop that you can set up using VNC or TightVNC - this VNC desktop you can then view on the same or different computer from either Windows or Linux.

The X.Org Foundation leads the X project and hosts reference implementation for it. X is available as free and open-source software under the MIT License. For more information on the X standard see the X.Org Foundation https://x.org/wiki/, and https://en.wikipedia.org/wiki/X_Window_System.

Exporting X display[edit]

You can export your Linux X display using the DISPLAY environment variable in Linux. This can be done either to another Linux machine or to a Windows machine where you are running a X server. The tips below indicate the procedure of how to export the display.

Export display from Linux to Linux[edit]

Assuming you have your Linux desktop open, and you want to log into another machine, let's call it remotepc, via ssh.

How to export display automatically via ssh -X option:

Open a terminal window. Type in the following:

 xhost +           # this will allow other systems to display to your machine
 ssh -X remotepc   # this will login in to remotepc and export the display to where you logged in from

This is all you should need to export the display to the desktop you logged in from. Test it out by starting another terminal, e.g. run: xterm & and see that the terminal pops up on your desktop.

If the -X option did not work, then from your local machine do as follows:

 ifconfig                       # find what IP address your machine is using
                                # e.g. consider that your machine has IP 192.168.0.1
 xhost +                        # allow other machines to connect to your display
 ssh remotepc                   # this login in to remotepc but doesn't attempt to automatically export display
 export DISPLAY=192.168.0.1:0   # explicitly export display to your local machine, to desktop 0

You should now be able to start programs on the remote machine and have any GUI for the program open up on your local machine. You could test it using xtern & and see if a new terminal window pops up.

Export display from Linux to Windows[edit]

In order to export the display from Linux to Windows, you need to have an XWindows server installed on your local machine. An excellent and free option is use of the XMing server available for Windows, see https://sourceforge.net/projects/xming/. Note with Windows 10 or 11 there is the new X410 app in the Windows app store ... this essentially provides all your X needs for Windows, see: https://x410.dev/.

Alternatively, you can set up a VNC server on the Linux machine you are logging in to, to create a virtual desktop. Then export the display to the VNC virtual display, and use a VNC viewer on Windows (or Linux) to view and interact with the virtual display.

On Ubuntu Linux, you can simply install a vncserver using apt-get, TightVNC server is suggested as it can save bandwidth, can install using: sudo apt install tightvncserver.

The following indicates how to setup and access a Linux GUI displays using XMing viewer on Windows:

 1. First install XMing on your Windows machine (see: https://sourceforge.net/projects/xming/)
 2. Once installed (and started, which happens after install by default) you will get a XMing logo appear in your taskbar:
XMing shown in taskbar
 3. The server number is likely 0:0, which means desktop 0 on the first display.
 4. On Windows you can use Putty or an alternate ssh client to log in to the Linux machine. In Putty, or the terminal you are using, make sure that you have enabled X11 forwarding. Check this by going to the Category panel in Putty. Open the Connection options. Under SSH, select Enable X11 forwarding, as shown in the screenshot below.
X11 forwarding in Putty
 5. You can now open the connection to the Linux machine. If your DISPLAY is not automatically forwarded, follow the export DISPLAY step mentioned above in the exporting from Linux to Linux but on your local machine use ipconfig from a command shell to find out what your IP address is.