# 3.5.目录结构

FreeBSD 的目录层级结构是理解整个系统的基础。根目录（“/”）是最重要的目录，它在启动时最先挂载，包含了操作系统的基础部分，为多用户操作做准备。根目录还包含了其他文件系统的挂载点，这些文件系统在进入多用户模式时被挂载。

挂载点是将额外文件系统附加到父文件系统（通常是根文件系统）上的目录。常见的挂载点包括 `/usr/`、`/var/`、`/tmp/`、`/mnt/` 和 `/media/`。这些目录在 `/etc/fstab` 文件中有条目。大多数文件系统会在启动时通过 [rc(8)](https://man.freebsd.org/cgi/man.cgi?query=rc\&sektion=8\&format=html) 脚本自动挂载，除非它们的条目包含 `noauto`。

文件系统层级的完整说明见 [hier(7)](https://man.freebsd.org/cgi/man.cgi?query=hier\&sektion=7\&format=html)。以下是常见目录的简要概述：

| 目录                | 说明                                                                                                                                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `/`               | 文件系统的根目录。                                                                                                                                                                                        |
| `/bin/`           | 单用户和多用户环境中必需的用户工具。                                                                                                                                                                               |
| `/boot/`          | 操作系统引导过程中使用的程序和配置文件。                                                                                                                                                                             |
| `/boot/defaults/` | 默认引导配置文件，参见 [loader.conf(5)](https://man.freebsd.org/cgi/man.cgi?query=loader.conf\&sektion=5\&format=html)。                                                                                     |
| `/dev/`           | 由 [devfs(5)](https://man.freebsd.org/cgi/man.cgi?query=devfs\&sektion=4\&format=html) 管理的设备特殊文件。                                                                                                 |
| `/etc/`           | 系统配置文件与脚本。                                                                                                                                                                                       |
| `/etc/defaults/`  | 默认系统配置文件，参见 [rc(8)](https://man.freebsd.org/cgi/man.cgi?query=rc\&sektion=8\&format=html)。                                                                                                       |
| `/etc/periodic/`  | 通过 [cron(8)](https://man.freebsd.org/cgi/man.cgi?query=cron\&sektion=8\&format=html) 每日、每周、每月运行的脚本，参见 [periodic(8)](https://man.freebsd.org/cgi/man.cgi?query=periodic\&sektion=8\&format=html)。 |
| `/lib/`           | `/bin` 和 `/sbin` 中二进制文件所需的关键系统库。                                                                                                                                                                 |
| `/libexec/`       | 关键系统文件。                                                                                                                                                                                          |
| `/media/`         | 可移动媒体（如 CD、USB 驱动器等）的挂载点子目录。                                                                                                                                                                     |
| `/mnt/`           | 系统管理员常用作临时挂载点的空目录。                                                                                                                                                                               |
| `/net/`           | 自动挂载的 NFS 共享，参见 [auto\_master(5)](https://man.freebsd.org/cgi/man.cgi?query=auto_master\&sektion=5\&format=html)。                                                                                |
| `/proc/`          | 进程文件系统。详见 [procfs(5)](https://man.freebsd.org/cgi/man.cgi?query=procfs\&sektion=4\&format=html)。                                                                                                 |
| `/rescue/`        | 紧急恢复用的静态链接程序。                                                                                                                                                                                    |
| `/root/`          | `root` 账户的主目录。                                                                                                                                                                                   |
| `/sbin/`          | 在单用户和多用户环境中必需的系统程序和管理工具。                                                                                                                                                                         |
| `/tmp/`           | 临时文件，通常在系统重启后*不会*保留。                                                                                                                                                                             |
| `/usr/`           | 大多数用户工具和应用程序所在之处。                                                                                                                                                                                |
| `/usr/bin/`       | 常用工具、编程工具和应用程序。                                                                                                                                                                                  |
| `/usr/include/`   | 标准 C 头文件。                                                                                                                                                                                        |
| `/usr/lib/`       | 存档库文件。                                                                                                                                                                                           |
| `/usr/libdata/`   | 杂项工具数据文件。                                                                                                                                                                                        |
| `/usr/libexec/`   | 系统守护进程及由其他程序执行的系统工具。                                                                                                                                                                             |
| `/usr/local/`     | 本地可执行文件与库，也是 FreeBSD ports 框架的默认安装位置。                                                                                                                                                            |
| `/usr/ports/`     | FreeBSD Ports（可选）。                                                                                                                                                                               |
| `/usr/sbin/`      | 由用户执行的系统守护进程与工具。                                                                                                                                                                                 |
| `/usr/share/`     | 架构无关文件。                                                                                                                                                                                          |
| `/usr/src/`       | BSD 和/或本地源代码文件。                                                                                                                                                                                  |
| `/var/`           | 用于日志、临时、中转与任务排队的多用途文件目录。                                                                                                                                                                         |
| `/var/log/`       | 系统日志文件。                                                                                                                                                                                          |
| `/var/tmp/`       | 临时文件，通常在系统重启后*会*保留。                                                                                                                                                                              |


---

# 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://book.bsdcn.org/hanbook/di-3-zhang-freebsd-ji-chu/3.5.-mu-lu-jie-gou.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.
