> For the complete documentation index, see [llms.txt](https://handbook.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://handbook.bsdcn.org/di-3-zhang-freebsd-ji-chu/3.5.-mu-lu-jie-gou.md).

# 3.5.目录结构

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

挂载点是将额外文件系统附加到父文件系统（通常是根文件系统）上的目录，详见 [磁盘结构](/di-3-zhang-freebsd-ji-chu/3.6.-ci-pan-jie-gou.md)。常见的挂载点包括 `/usr/`、`/var/`、`/tmp/`、`/mnt/` 和 `/media/`。这些目录通常与 `/etc/fstab` 文件中的条目相对应。该文件是各种文件系统和挂载点的配置表，由系统读取。大多数文件系统会在引导时通过 [rc(8)](https://man.freebsd.org/cgi/man.cgi?query=rc\&sektion=8\&format=html) 脚本自动挂载，除非它们的条目包含 `noauto`。详见 [fstab 文件](/di-3-zhang-freebsd-ji-chu/3.7.-wen-jian-xi-tong-de-gua-zai-yu-xie-zai.md)。

文件系统层级的完整说明见 [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=5\&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=5\&format=html)。                                                                                                                                                                             |
| `/rescue/`        | 紧急恢复用的静态链接程序，参见 [rescue(8)](https://man.freebsd.org/cgi/man.cgi?query=rescue\&sektion=8\&format=html)。                                                                                                                                                                       |
| `/root/`          | `root` 账户的主目录。                                                                                                                                                                                                                                                               |
| `/sbin/`          | 在单用户和多用户环境中必需的系统程序和管理工具。                                                                                                                                                                                                                                                     |
| `/tmp/`           | 临时文件，通常在系统重启后*不会*保留。通常会在 `/tmp` 上挂载基于内存的文件系统，这可以通过 [rc.conf(5)](https://man.freebsd.org/cgi/man.cgi?query=rc.conf\&sektion=5\&format=html) 中与 tmpmfs 相关的变量自动完成，或在 `/etc/fstab` 中添加条目，详见 [mdmfs(8)](https://man.freebsd.org/cgi/man.cgi?query=mdmfs\&sektion=8\&format=html)。 |
| `/usr/`           | 大多数用户工具和应用程序所在之处。                                                                                                                                                                                                                                                            |
| `/usr/bin/`       | 常用工具、编程工具和应用程序。                                                                                                                                                                                                                                                              |
| `/usr/include/`   | 标准 C 头文件。                                                                                                                                                                                                                                                                    |
| `/usr/lib/`       | 存档库文件。                                                                                                                                                                                                                                                                       |
| `/usr/libdata/`   | 杂项工具数据文件。                                                                                                                                                                                                                                                                    |
| `/usr/libexec/`   | 系统守护进程及由其他程序执行的系统工具。                                                                                                                                                                                                                                                         |
| `/usr/local/`     | 本地可执行文件与库，也是 FreeBSD ports 框架的默认安装位置。在 `/usr/local` 中，应遵循 [hier(7)](https://man.freebsd.org/cgi/man.cgi?query=hier\&sektion=7\&format=html) 中为 `/usr` 所说明的通用布局。例外情况是 man 目录直接位于 `/usr/local` 下而非 `/usr/local/share` 下，以及 ports 文档位于 `share/doc/port` 中。                      |
| `/usr/ports/`     | FreeBSD Ports（可选）。                                                                                                                                                                                                                                                           |
| `/usr/sbin/`      | 由用户执行的系统守护进程与工具。                                                                                                                                                                                                                                                             |
| `/usr/share/`     | 架构无关文件。                                                                                                                                                                                                                                                                      |
| `/usr/src/`       | BSD 和/或本地源代码文件。                                                                                                                                                                                                                                                              |
| `/var/`           | 用于日志、临时、中转与任务排队的多用途文件目录。                                                                                                                                                                                                                                                     |
| `/var/log/`       | 杂项系统日志文件。                                                                                                                                                                                                                                                                    |
| `/var/tmp/`       | 临时文件，通常在系统重启后*会*保留。                                                                                                                                                                                                                                                          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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