HOW TO USE GUI BASED APPLICATIONS IN LINUX ENVIRONMENTS – PART 2
We discussed how to open graphical applications in Linux in Part 1. In this second part, let us learn more about X11. This post is more of a personal notes for my future reference. For detailed technical information, please refer to relevant documentation.
The X Windows system, also known as X11 or simply X, is a windowing system for Unix-like operating systems. X system uses client-server model. Here, X client is a remote application we want to access and X server is the program that displays windows in front of the user.
This client–server terminology – the user’s terminal being the server and the applications being the clients – often confuses new X users, because the terms appear reversed. But X takes the perspective of the application, rather than that of the end-user: X provides display and I/O services to applications, so it is a server; applications use these services, thus they are clients. Unlike most earlier display protocols, X was specifically designed to be used over network connections rather than on an integral or attached display device. X features network transparency, which means an X program running on a computer somewhere on a network (such as the Internet) can display its user interface on an X server running on some other computer on the network.(Source: wikipedia). Examples of X server are xming, Exceed etc.
DISPLAY environment variable is one the most important variables that X client use. X clients use this variable to decide to which X server it needs to send graphic windows. X uses a three part name for displays in the form hostname:displaynumber.screennumber where hostname is the computer host name, displaynumber whch is a number starting at 0 that describes the particular display, and screennumber applies if two or more monitors are treated as separate screens rather than as a single logical screen. Both hostname and screennumber can be omitted, so the most common display notation you will see is :0. (Source: IBM Developer Works). The DISPLAY values are usually like :0, :0.0 if X server and applications are on the same host. X server for a display listens at TCP port 6000+D. That is if display number is 10, X server listens at 6010.
There are different ways to open X based applications:
- Access GUI applications directly from Linux Desktop which got all graphic related packages installed. No additional setup is required in this case and DISPLAY variable is set to :0.
- If remote X client program and X server are located on same network: We need to set DISPLAY variable to “yourDesktopIP:0“. I have simulated this setup on my laptop by creating Ubuntu machine using Virtual box and connecting both of them by changing network Virtualbox adapter settings(Refer here). This makes both Windows (host) and Ubuntu on same network. I have also added remote server host and ips in Xming X0.hosts file.
- The third method is X11 forwarding: In this case, both remote and local workstation (X server) need not be in same network but local workstation should be able to access remote machine using ssh. For this, there is no need to set DISPLAY variable manually. This can be acheived either by adding -X option from bash terminal ssh command or enabling X11 forwarding from Putty session. The sshd on the remote host will set up an X11 proxy on that host, and will set up the DISPLAY variable and the ~/.Xauthority file on the remote host appropriately for the connection. Basically, whatever traffic X client program sends to localhost:D.S (localhost:6000 + D) is forwarded to localhost and user workstation (local X server). For detailed configuration steps refer to Part 1.
Difference between VNC and X11:
VNC (Virtual Network Computing) can be used to remotely access graphical application. VNC sends whole desktop to user while X11 only displays relevant program. VNC session survives between network connections whereas X11 session immediately terminates.
Comments
Post a Comment