XHOST Command

Using XHOST in terminal to control access to the X server.

3345 views

Edited: 2019-12-03 17:24

Linux article image.

XHOST is used to manage a list of hosts and users allowed to access the X Server on a system, which can both be accessed from other hosts and other users on the same system.

Typically, remote access will be disabled, as it poses a security risk. But, if you need to run a GUI application on a remote computer, and have the GUI show up on your own screen, XHOST can be used to allow the remote computer.

Sometimes other users on the same system may also need access to another users X. A situation where this can happen, is when a desktop user is running a GUI as root.

Using XHOST to manage access

If you need to allow root to access the x server for a user on your system, typically in single-user enviroments, you can do so by typing the below command in terminal, while logged in as said user:

xhost +si:localuser:root

Note. All commands should be typed without sudo.

Refer to the below reference for more commands, and be careful not to allow remote access, unless you know what you are doing.

xhost +si:localuser:some_user Grants "some_user" access to the "localuser" X, (localuser refers to the user who is currently logged in.)
xhost -si:localuser:some_user Revokes access of "some_user".
XHOST +local:Only allow access from the local network.
XHOST -local:Disallows local access.
XHOST +Disables access control. Warning: This allows all access, including remote access!
XHOST -Turns access control back on.

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. How to search a directory and subdirectories for a given string of text in Linux with the grep command.
  3. Worth knowing in order to make a bootable USB memory stick with Windows on from Linux.
  4. This is why I decided to encrypt my new Flash Drive, and why I think you should too.
  5. About the problem with using sudo with graphical programs in Linux.

More in: Linux Tutorials