# xhost

制哪些X客户端能够在X服务器上显示

## 补充说明

**xhost命令** 是X服务器的访问控制工具，用来控制哪些X客户端能够在X服务器上显示。该命令必须从有显示连接的机器上运行。可以通过使用`-host`参数，从访问列表中除去一个名称。不要从访问列表中除去当前的名称。如果已经这样做了，请在作出任何更改之前注销系统。

### 语法

```
xhost(参数)
```

### 参数

* +：关闭访问控制，允许任何主机访问本地的X服务器；
* -：打开访问控制，仅允许授权清单中的主机访问本地的X服务器。

输入无变量的xhost命令将显示访问X服务器的当前主机名，并显示一条消息表明访问是否已启用。

为了安全起见，只能从控制主机运行影响访问控制的选项。对于工作站来说，这台机器也就是服务器。对于X终端来说，这台机器是登录主机。

要在缺省情况下启用远程名称，可以在`/etc/X?.hosts`文件中定义名称，其中`?`为启用访问的显示器号。

例如，显示器`jeanne:0`可以由使用jeanne的缺省主机名的系统上的`/etc/X0.hosts`文件中定义的系统访问。在显示名称和文件名中，0表明已定义的远程系统允许通过增强X-Windows访问的显示器号。

注意：`-name`参数，定义要从X服务器访问列表中除去的主机名。已有的连接没有被中断，但将拒绝新的连接请求。注意：可以除去当前的机器；然而，不允许进行进一步的连接（包括试图将其添加回来）。再一次启用本地连接的唯一方法就是将服务器复位（因此也会中断所有连接）。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/linux/ming-ling/xhost.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
