1. Technology

Your suggestion is on its way!

An email with a link to:

http://linux.about.com/library/cmd/blcmdl_xhost.htm

was emailed to:

Thanks for sharing About.com with others!

Linux / Unix Command: xhost
Command Library

"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. In this article we describe a simple method to do your work on any computer on the network without leaving your seat.

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.

>> Linux Command Library Index

>> Also see Shell Command Library

You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

©2014 About.com. All rights reserved.