A Debian system is organized along the Filesystem Hierarchy Standard (FHS). This standard defines the purpose of each directory. For instance, the top-level directories are described as follows:
/bin/
:基本程序;
/boot/
: Linux 内核和在早期启动流程中需要的其它文件;
/dev/
: 设备文件;
/etc/
: 配置文件;
/home/
: 用户个人文件;
/lib/
:基础库;
/media/*
: 可移动设备挂载点 (CD-ROM, U 盘等等);
/mnt/
: 临时挂载点;
/opt/
: 有第三方提供的额外应用程序;
/root/
: 管理员(root)的个人文件;
/run/
: 易失性数据,在重启后不会存在;
/sbin/
: 系统程序;
/srv/
: 在这个系统上的服务使用的数据 ;
/tmp/
: 临时文件;这个目录在启动的时候经常被清空;
/usr/
: applications; this directory is further subdivided into bin
, sbin
, lib
(according to the same logic as in the root directory). Furthermore, /usr/share/
contains architecture-independent data. /usr/local/
is meant to be used by the administrator for installing applications manually without overwriting files handled by the packaging system (dpkg
).
/var/
: variable data handled by daemons. This includes log files, queues, spools, caches and so on.
/proc/
and
/sys/
are specific to the Linux kernel (and not part of the FHS). They are used by the kernel for exporting data to user space (see
第 B.3.4 节 “用户空间” and
第 B.5 节 “用户空间” for explanations about this concept).
Note that many modern distributions, Debian included, are shipping /bin
, /sbin
and /lib
as symlinks to the corresponding directories below /usr
so that all programs and libraries are available in a single tree. It makes it easier to protect the integrity of the system files, and to share those system files among multiple containers, etc.
The contents of a user's home directory is not standardized, but there are still a few noteworthy conventions. One is that a user's home directory is often referred to by a tilde (“~”). That is useful to know because command interpreters automatically replace a tilde with the correct directory (usually /home/user/
).
Traditionally, application configuration files are often stored directly under the user's home directory, but their names usually start with a dot (for instance, the mutt
email client stores its configuration in ~/.muttrc
). Note that filenames that start with a dot are hidden by default; and ls
only lists them when the -a
option is used, and graphical file managers need to be told to display hidden files.
Some programs also use multiple configuration files organized in one directory (for instance, ~/.ssh/
). Some applications also use their directory to store a cache of downloaded data. This means that those directories can end up using a lot of disk space.
These configuration files stored directly in a user's home directory, often collectively referred to as dotfiles, have long proliferated to the point that these directories can be quite cluttered with them. Fortunately, an effort led collectively under the FreeDesktop.org umbrella has resulted in the “XDG Base Directory Specification”, a convention that aims at cleaning up these files and directories. This specification states that configuration files should be stored under ~/.config/
, cache files under ~/.cache/
, and application data files under ~/.local/
(or subdirectories thereof). This convention has been gaining traction, and many applications (especially graphical ones) are following it.
Graphical desktops usually display the contents of the ~/Desktop/
directory (or whatever the appropriate translation is for systems not configured in English) on the desktop (i.e. what is visible on screen once all applications are closed or iconized).
Finally, the email system sometimes stores incoming emails into a ~/Mail/
directory.