Linux xhost command
On Unix-like operating systems, the xhost command is a server access control program for X. It adds and deletes hostnames or user names to the list allowed to make connections to the X server.
Description
In the case of hosts, xhosts provides a rudimentary form of privacy control and security. It is only sufficient for a workstation (single user) environment, although it does limit the worst abuses in other cases. Environments which require more sophisticated measures should implement the user-based mechanism or use the hooks in the protocol for passing other authentication data to the server.
Syntax
xhost [[+-]name ...]
Options
xhost accepts the following command line options described below. For security, the options that affect access control may only run from the "controlling host". For workstations, this is the same machine as the server. For X terminals, it is the login host.
-help | Display a help message, and exit. |
[+]name | The given name (the plus sign is optional) is added to the list allowed to connect to the X server. The name is a hostname or a complete name (See the names section below for more details). |
-name | The given name is removed from the list of allowed to connect to the server. The name is a hostname or a complete name (see the names section below for more details). Existing connections are not broken, but new connection attempts will be denied. Note that the current machine is allowed to be removed; however, further connections (including attempts to add it back) are not permitted. Resetting the server (thereby breaking all connections) is the only way to allow local connections again. |
+ | Access is granted to everyone, even if they aren't on the list (i.e., access control is turned off). |
- | Access is restricted to only those on the list (i.e., access control is turned on). |
[nothing] | If no command line arguments are given, a message indicating whether or not access control is currently enabled is printed, followed by the list of those allowed to connect. This option is the only option used from machines other than the controlling host. |
Names
A complete name has the syntax "family:name" where the families are as follows:
inet | Internet host (IPv4). |
inet6 | Internet host (IPv6). |
dnet | DECnet host. |
nis | Secure RPC network name. |
krb | Kerberos V5 principal. |
local | Contains only one name, the empty string. |
si | Server Interpreted. |
The family is case-insensitive. The format of the name varies with the family.
When Secure RPC is used, the network independent netname (e.g., "nis:unix.uid@domainname") can be specified, or a local user can be specified with the username and a trailing at sign (e.g., "nis:pat@"). For backward compatibility with pre-R6 xhost, names that contain an at sign (@) are assumed to be in the nis family. Otherwise, they are assumed to be Internet addresses. If compiled to support IPv6, then all IPv4 and IPv6 addresses returned by getaddrinfo are added to the access list in the appropriate inet or inet6 family.
The local family specifies all the local connections at once. However, the server interpreted address "si:localuser:username" can specify a single local user.
Server interpreted addresses consist of a case-sensitive type tag and a string representing a given value, separated by a colon. For example, "si:hostname:almas" is a server interpreted address of type hostname, with a value of almas.
The initial access control list for display number n may be set by the file /etc/Xn.hosts, where n is the display number of the server.
Examples
xhost +
Allow users to connect to the X server.
Related commands
X — Executable of the X Window System.
startx — Start an X Window System session.
xorg — The executable of the X Window System server.