# 5.4.安装 X.org 服务器

**摘要**：必须安装 [X.org](https://cgit.freebsd.org/ports/tree/x11/xorg/) 服务器以承载 [桌面](https://docs.freebsd.org/en/books/handbook/desktop/#desktop-synopsis)。必须把用户添加到 `video` 组才能使用它。

待显卡驱动安装并启用后，可以作为元包安装 X.org 服务器，也可以通过 Ports 树在本地编译。

完整元包安装速度快，但可自定义选项较少：

```sh
# pkg install xorg
```

此安装将完整的 X Window 系统安装到系统中，包括传统窗口管理器 [twm(1)](https://man.freebsd.org/cgi/man.cgi?query=twm\&sektion=1\&format=html) 以及传统桌面套件。大多数用户会希望安装并配置自己选择的现代 [桌面](https://docs.freebsd.org/en/books/handbook/desktop/#desktop-synopsis)。

当前用户必须是 `video` 组的成员才能运行图形环境。要将用户添加到 `video` 组，请执行以下命令：

```sh
# pw groupmod video -m username
```

要运行 X Window 系统，可使用来自 [x11/xinit](https://cgit.freebsd.org/ports/tree/x11/xinit/) 的 [startx(1)](https://man.freebsd.org/cgi/man.cgi?query=startx\&sektion=1\&format=html)，或安装并配置显示管理器，在启动时进行图形登录。

> **技巧**
>
> 面向高级用户的精简版 X Window System 可通过 [x11/xorg-minimal](https://cgit.freebsd.org/ports/tree/x11/xorg-minimal/) 获得。大部分文档、库和应用程序不会被安装，部分应用程序需要这些额外组件才能正常运行。


---

# 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://handbook.bsdcn.org/di-5-zhang-xwindow-xi-tong/5.4.-xorg-pei-zhi.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.
