Run Software on Different Linux Machines With xhost

In contrast to the typical use of Windows-based home 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. Linux supports rapid and stable connections to other computers and running graphical user interfaces over the network. 

The primary command for executing these network activities is xhost — the server access control program for X. The xhost program is used to add and delete host (computer) names or usernames to the list of machines and users that are allowed to make connections to the X server. This framework provides a rudimentary form of privacy control and security.

Person using a laptop

Usage Scenario

Let's call the computer you are sitting at the "localhost" 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 localhost. 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 Use Case

Assume the IP address of the local host is and the IP address of the remote host is Depending on the network you are on, you may also be able to use the computer names (domain names) instead of the IP addresses.

  1.  Type the following at the command line of the localhost:

    xhost +
  2. Log on to the remote host:

  3. On the remote host (through the telnet connection), instruct the remote host to display windows on the local host by typing:

    setenv DISPLAY

    (Instead of setenv you may have to use export on certain shells.)

  4. Now you can run software on the remote host. For example, when you type "xterm" on the remote host, you should see an xterm window on the local host.

  5. After you finish, you should remove the remote host from your access control list as follows. On the local host type:

    xhost -

Quick Reference

The xhost command contains just a few variations to help you with your networking:

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

Because Linux distributions and kernel-release levels differ, use the man command (% man) to see how xhost is implemented in your particular computing environment.

Was this page helpful?