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:
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.|