Search This Blog

Saturday 4 June 2011

Linux / Unix Command: xhost (Little Networking on Linux)

Linux / Unix Command: xhost (Little Networking on Linux)

In contrast to the typical use of traditional "personal" computers, in Linux/Unix environments, working "on the network" has always been the norm, which explains the powerful networking features of Unix and Linux operating systems. You can easily connect to other computers and run graphical user interfaces over the network.

The key command is: xhost - the server access control program for X. The xhost program is used to add and delete host (computer) names or user names to the list of machines and users that are allowed to make connections to the X server. This provides a rudimentary form of privacy control and security.

Overview: Let's call the computer you are sitting at the "local host" and the computer you want to connect to the "remote host". You first use xhost to specify which computer(s) you want to give permission to connect to (the X-server of) the local host. Then you connect to the remote host using telnet. Next you set the DISPLAY variable on the remote host. You want to set this DISPLAY variable to the local host. Now when you start up a program on the remote host, its GUI will show up on the local host (not on the remote host).

Example of a Typical Use:-
Assume the IP address of the local host is 128.100.2.16 and the IP address of the remote host is 17.200.10.5. Depending on the network you are on, you may also be able to use the computer names (domain names) instead of the IP addresses.

Step 1. On the local host


Type the following at the command line:


% xhost + 17.200.10.5
< press return >


Step 2. Log on to the remote host


% telnet 17.200.10.5


Step 3. On the remote host (through the telnet connection)


Instruct the remote host to display windows on the local host by typing:


% setenv DISPLAY 128.100.2.16:0.0


at the command line. (Instead of setenv you may have to use export on certain shells.)


< press return >


Step 4. Now you can run software from the remote host.


E.g.: when you type % xterm on the remote host, you should see an xterm window on the local host.


Step 5. After You Finish


You should remove the remote host from your access control list as follows. On the local host type:


% xhost - 17.200.10.5 
< press return >

--------------------------------------------------------------------------------------------

Quick Reference - xhost
xhost + hostname: Adds hostname to X server access control list.
xhost - hostname: Removes hostname from X server access control list.
xhost + : Turns off acccess control (all remote hosts will have access to X server)
xhost - : Turns access control back on.


Important: Use the man command (% man) to see how a command is used on your particular computer.
Related Posts Plugin for WordPress, Blogger...