> For the complete documentation index, see [llms.txt](https://dev2ero.gitbook.io/notes-cs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev2ero.gitbook.io/notes-cs/operating-system/tong-yong-cao-zuo-xi-tong/linux/wen-jian-xi-tong/linux-wen-jian-xi-tong-mu-lu-miao-shu.md).

# Linux 文件系统目录描述

| Directory or file                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/`                                            | The slash `/` character alone denotes the root of the filesystem tree.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `/bin`                                         | Stands for [binaries](https://en.wikipedia.org/wiki/Computer_program) and contains certain fundamental utilities, such as `ls` or `cp`, that are needed to mount `/usr`, when that is a separate filesystem, or to run in one-user (administrative) mode when `/usr` cannot be mounted. In System V.4, this is a symlink to `/usr/bin`. Otherwise, it needs to be on the root filesystem itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [`/boot`](https://en.wikipedia.org/wiki//boot) | Contains all the files needed for successful booting process. In [Research Unix](https://en.wikipedia.org/wiki/Research_Unix), this was one file rather than a directory.[\[14\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-upe-14) Nowadays usually on the root filesystem itself, unless the system, bootloader etc. require otherwise.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [`/dev`](https://en.wikipedia.org/wiki//dev)   | Stands for devices. Contains [file representations](https://en.wikipedia.org/wiki/Device_node) of peripheral devices and [pseudo-devices](https://en.wikipedia.org/wiki/Device_file#Pseudo-devices). See also: [Linux Assigned Names and Numbers Authority](https://en.wikipedia.org/wiki/Linux_Assigned_Names_and_Numbers_Authority). Needs to be on the root filesystem itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `/etc`                                         | Contains system-wide configuration files and system databases; the name stands for [et cetera](https://en.wikipedia.org/wiki/Et_cetera).[\[14\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-upe-14) Originally also contained "dangerous maintenance utilities" such as `init`,[\[6\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-v7-6) but these have typically been moved to `/sbin` or elsewhere. Needs to be on the root filesystem itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `/home`                                        | Contains user home directories on Linux and some other systems. In the original version of Unix, home directories were in `/usr` instead.[\[15\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-notes72-15) Some systems use or have used different locations still: [macOS](https://en.wikipedia.org/wiki/MacOS) has home directories in `/Users`, older versions of BSD put them in `/u`, [FreeBSD](https://en.wikipedia.org/wiki/FreeBSD) has `/usr/home`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `/lib`                                         | Originally essential libraries: [C](https://en.wikipedia.org/wiki/C_\(programming_language\)) libraries, but not [Fortran](https://en.wikipedia.org/wiki/Fortran) ones.[\[14\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-upe-14) On modern systems, it contains the shared libraries needed by programs in `/bin`, and possibly [loadable kernel module](https://en.wikipedia.org/wiki/Loadable_kernel_module) or [device drivers](https://en.wikipedia.org/wiki/Device_driver). Linux distributions may have variants `/lib32` and `/lib64` for multi-architecture support.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `/media`                                       | Default mount point for removable devices, such as USB sticks, media players, etc. By common sense, the directory itself, whose subdirectories are mountpoints, is on the root partition itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `/mnt`                                         | Stands for mount. Empty directory commonly used by system administrators as a temporary mount point. By common sense, the directory itself, whose subdirectories are mountpoints, is on the root partition itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `/opt`                                         | Contains locally installed software. Originated in [System V](https://en.wikipedia.org/wiki/UNIX_System_V), which has a [package manager](https://en.wikipedia.org/wiki/Package_manager) that installs software to this directory (one subdirectory per package).[\[16\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-16)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `/proc`                                        | [procfs](https://en.wikipedia.org/wiki/Procfs) virtual [filesystem](https://en.wikipedia.org/wiki/File_system) showing information about [processes](https://en.wikipedia.org/wiki/Process_\(computing\)) as files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `/root`                                        | The home directory for the [superuser](https://en.wikipedia.org/wiki/Superuser) root - that is, the system administrator. This account's home directory is usually on the initial filesystem, and hence not in /home (which may be a mount point for another filesystem) in case specific maintenance needs to be performed, during which other filesystems are not available. Such a case could occur, for example, if a hard disk drive suffers physical failures and cannot be properly mounted. By convention, this directory is on the root partition itself; in any case, it is not a link to `/home/root` or any such thing.                                                                                                                                                                                                                                                                                                                                                                                                     |
| `/sbin`                                        | Stands for "[system (or superuser) binaries](https://en.wikipedia.org/wiki/Computer_program)" and contains fundamental utilities, such as `init`, usually needed to start, maintain and recover the system. Needs to be on the root partition itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `/srv`                                         | Server data (data for services provided by system).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `/sys`                                         | In some [Linux distributions](https://en.wikipedia.org/wiki/Linux_distribution), contains a [sysfs](https://en.wikipedia.org/wiki/Sysfs) virtual [filesystem](https://en.wikipedia.org/wiki/File_system), containing information related to hardware and the operating system. On BSD systems, commonly a symlink to the kernel sources in `/usr/src/sys`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/tmp`                                         | A place for temporary files not expected to survive a reboot. Many systems clear this directory upon startup or use [tmpfs](https://en.wikipedia.org/wiki/Tmpfs) to implement it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `/unix`                                        | The Unix [kernel](https://en.wikipedia.org/wiki/Kernel_\(computing\)) in Research Unix and [System V](https://en.wikipedia.org/wiki/UNIX_System_V).[\[14\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-upe-14) With the addition of [virtual memory](https://en.wikipedia.org/wiki/Virtual_memory) support to [3BSD](https://en.wikipedia.org/wiki/Berkeley_Software_Distribution#3BSD), this got renamed `/vmunix`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `/usr`                                         | The "user file system": originally the directory holding user home directories,[\[15\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-notes72-15) but already by the Third Edition of [Research Unix](https://en.wikipedia.org/wiki/Research_Unix), ca. 1973, reused to split the operating system's programs over two disks (one of them a 256K fixed-head drive) so that basic commands would either appear in `/bin` or `/usr/bin`.[\[17\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-reader-17) It now holds executables, libraries, and shared resources that are not system critical, like the [X Window System](https://en.wikipedia.org/wiki/X_Window_System), [KDE](https://en.wikipedia.org/wiki/KDE), [Perl](https://en.wikipedia.org/wiki/Perl), etc. In older Unix systems, user home directories might still appear in `/usr` alongside directories containing programs, although by 1984 this depended on local customs.[\[14\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-upe-14) |
| `/usr/include`                                 | Stores the development headers used throughout the system. [Header files](https://en.wikipedia.org/wiki/Header_file) are mostly used by the `#include` directive in [C](https://en.wikipedia.org/wiki/C_\(programming_language\)) language, which historically is how the name of this directory was chosen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `/usr/lib`                                     | Stores the needed libraries and data files for programs stored within `/usr` or elsewhere.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/usr/libexec`                                 | Holds programs meant to be executed by other programs rather than by users directly. E.g., the [Sendmail](https://en.wikipedia.org/wiki/Sendmail) executable may be found in this directory.[\[18\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-18) Not present in the FHS until 2011;[\[19\]](https://en.wikipedia.org/wiki/Unix_filesystem#cite_note-19) Linux distributions have traditionally moved the contents of this directory into `/usr/lib`, where they also resided in 4.3BSD.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `/usr/local`                                   | Resembles `/usr` in structure, but its subdirectories are used for additions not part of the operating system distribution, such as custom programs or files from a [BSD](https://en.wikipedia.org/wiki/BSD) [Ports collection](https://en.wikipedia.org/wiki/Ports_collection). Usually has subdirectories such as `/usr/local/lib` or `/usr/local/bin`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `/usr/share`                                   | Architecture-independent program data. On Linux and modern BSD derivatives, this directory has subdirectories such as `man` for [manpages](https://en.wikipedia.org/wiki/Manpage), that used to appear directly under `/usr` in older versions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `/var`                                         | Stands for variable. A place for files that might change frequently - especially in size, for example e-mail sent to users on the system, or process-ID [lock files](https://en.wikipedia.org/wiki/Lock_file).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `/var/log`                                     | Contains system log files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/var/mail`                                    | The place where all incoming mail is stored. Users (other than `root`) can access their own mail only. Often, this directory is a [symbolic link](https://en.wikipedia.org/wiki/Symbolic_link) to `/var/spool/mail`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `/var/spool`                                   | [Spool](https://en.wikipedia.org/wiki/Spooling) directory. Contains print jobs, mail spools and other queued tasks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `/var/src`                                     | The place where the uncompiled source code of some programs is.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `/var/tmp`                                     | The `/var/tmp` directory is a place for temporary files which should be preserved between system reboots.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
