Difference between revisions of "Arch filesystem hierarchy (简体中文)"

From ArchWiki
Jump to: navigation, search
(/usr/include: 头文件)
m (/bin: 基本命令的二进制文件)
Line 23: Line 23:
  
 
===/bin: 基本命令的二进制文件===
 
===/bin: 基本命令的二进制文件===
传统上,二进制文件存放目录必须在但用户模式下可访问,且可被任何用户访问(例如cat,ls,cp命令)。这样即使在只有根目录/所在分区被挂载,/bin/目录下的程序也能被访问。但实际上,Arch上并非如此,因为所有必须的库都在/usr/lib目录下。Arch开发者计划在将来将/bin目录合并至/usr/bin目录。不像/sbin(其中包含的命令只能被root用户使用),/bin目录意在包含能同时被root用户和非root用户使用的命令。
+
传统上,二进制文件存放目录必须在单用户模式下可访问,且可被任何用户访问(例如cat,ls,cp命令)。这样即使在只有根目录/所在分区被挂载,/bin/目录下的程序也能被访问。但实际上,Arch上并非如此,因为所有必须的库都在/usr/lib目录下。Arch开发者计划在将来将/bin目录合并至/usr/bin目录。不像/sbin(其中包含的命令只能被root用户使用),/bin目录意在包含能同时被root用户和非root用户使用的命令。
  
 
===/boot: 静态bootloader文件===
 
===/boot: 静态bootloader文件===

Revision as of 14:29, 31 March 2013

Template:Article summary start Template:Article summary text Template:Article summary end Arch Linux是众多遵守文件系统层次标准(FHS,filesystem hierarchy standard)中的一种。除了描述不同目录和其设计,本文还将涵盖Arch特有的更改。

文件系统层次标准

引用至 文件系统层次标准的主页 (FHS):

"文件系统标准是设计给Unix发行版开发者、包开发者和系统实现者使用的。然而,它首先意在作为一个参考而不是一个如何管理Unix文件系统或目录层次的教程。"

可共享文件和不可共享文件

可共享文件是指那些能保存在某个主机而被其他主机上的用户使用的文件。 不可共享文件是指那些不可被其他主机上的用户使用的文件。例如,用户家目录可共享而设备锁文件不可共享。 静态文件包括二进制、库、文档文件和其他系统管理员才能变更的文件。 可变文件即非静态文件。

目录

根文件系统

根文件系统,用斜杠自身表示(/),是最基本的文件系统,其他所有文件系统起源于此,是(文件系统)层次的顶端。所有文件和目录都出现在根目录"/"之下,即使它们存储在不同的物理设备上。根文件系统的内容必须能够引导启动或者修复系统。 All files and directories appear under the root directory "/", even if they are stored on different physical devices. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system.

/bin: 基本命令的二进制文件

传统上,二进制文件存放目录必须在单用户模式下可访问,且可被任何用户访问(例如cat,ls,cp命令)。这样即使在只有根目录/所在分区被挂载,/bin/目录下的程序也能被访问。但实际上,Arch上并非如此,因为所有必须的库都在/usr/lib目录下。Arch开发者计划在将来将/bin目录合并至/usr/bin目录。不像/sbin(其中包含的命令只能被root用户使用),/bin目录意在包含能同时被root用户和非root用户使用的命令。

/boot: 静态bootloader文件

非共享静态目录,包含内核镜像、内存盘(ramdisk)镜像文件、启动器(bootloader)配置文件和bootloader stage(真不知道怎么翻译了,都懂的)文件。内核开始工作前,可能会执行一些用户空间程序,这些程序所需的数据也保存在/boot中。这些数据可能包括主引导扇区(boot sector)和扇区映射表(sector map)文件。

/dev: 设备文件

系统启动期间udev和检测到硬件(产生相应事件)时创建的基本设备节点保存在该目录下。该目录突出了UNIX文件系统一个重要的特性——一切皆文件(或目录,其实目录也是文件)。查看这个目录,你会发现一大堆文件,每个文件代表系统的一个硬件组件。多数设备是块设备或字符设备,但也存在其他设备类型且可以被创建。一般来说,‘块设备’是保存或容纳数据的设备,而‘字符设备’可以被看成传送或转移数据的设备。例如,硬盘驱动器和光驱被归类为块设备而串行端口、鼠标和USB接口都是字符设备。

/etc: 主机相关的配置

Host-specific, unsharable configuration files shall be placed in the /etc directory. If more than one configuration file is required for an application, it is customary to use a subdirectory in order to keep the /etc/ area as clean as possible. It is considered good practice to make frequent backups of this directory as it contains all system related configuration files.

/etc/X11

X视窗系统的配置文件

/etc/X11/xinit

xinit配置文件。'xinit'是一个启动X会话的配置方法,被设计成作为一个脚本的一部分来使用。

/etc/X11/xinit/xinitrc

全局xinitrc文件,被所有由xinit(startx命令)启动的X会话使用。该文件的设置会被位于用户家目录的.xinitrc文件覆盖。

/home: 用户目录

UNIX是一个多用户环境。因此,每个用户都被分配了一个特定的目录,该目录只允许其所属的用户和root用户访问。这就是用户家目录,可以在'/home/$USER'(~/)下被找到。在其家目录中,用户可以写文件、删除它们、安装程序等等。用户的家目录包含他们的数据和个人配置文件,所谓的'点文件'(文件名前有一个点),这些'点文件'是隐藏文件。要查看点文件,需要打开文件管理器的相应选项或使用带-a开关的ls命令。如果个人配置文件和系统级配置文件有冲突,个人配置文件中的设置具有更高优先级。最终用户最可能更改的点文件包括.xinitrc和.bashrc文件,这两个文件分别用于配置xinit和Bash。它们允许用户能够改变窗口管理器,使其登录时就被启动,同时允许别名(alias),用户定义的命令和环境变量。当某个用户被创建时,系统会从/etc/shel目录,存放系统样本文件的目录,获取其点文件。

/home目录可能变得相当大,因为它通常用于存储下载、编译、安装、程序运行、邮件、多媒体集等文件。

/lost+found: 文件系统相关的可恢复数据

UNIX-like operating systems must execute a proper shutdown sequence. At times, a system might crash or a power failure might take the machine down. Either way, at the next boot, a filesystem check using the fsck program shall be performed. Fsck will go through the system and try to recover any corrupt files that it finds. The result of this recovery operation will be placed in this directory. The files recovered are not likely to be complete or make much sense but there always is a chance that something worthwhile is recovered.

/mnt: 临时挂载点

This is a generic mount point for temporary filesystems or devices. Mounting is the process of making a filesystem available to the system. After mounting, files will be accessible under the mount-point. Additional mount-points (subdirectories) may be created under /mnt/. There is no limitation to creating a mount-point anywhere on the system, but by convention and for practicality, littering a file system with mount-points should be avoided.

/opt: 不确定的软件包

Packages and large static files that do not fit cleanly into the above GNU filesystem layout can be placed in /opt. A package placing files in the /opt/ directory creates a directory bearing the same name as the package. This directory in turn holds files that otherwise would be scattered throughout the file system. For example, the acrobat package has Browser, Reader, and Resource directories sitting at the same level as the bin directory. This doesn't fit into a normal GNU filesystem layout, so Arch places all the files in a subdirectory of /opt.

/proc: 进程信息

/proc目录的特别之处在于它也是一个虚拟文件系统。它有时候被称为“进程信息伪文件系统”。它不包含‘真实’的文件,却包含运行时系统信息(例如系统内存、设备挂载、硬件配置等信息)。因此它可以被当做内核的控制和信息中心。实际上,相当多系统程序仅仅是对该目录中文件的调用。例如,‘lsmod’就是‘cat /proc/modules’而‘lspci’和‘cat /proc/pci’一样。系统运行时,改变该目录下的文件,内核参数可能被读取或改变(sysctl)。

该目录下的文件最有特点的一面是所有的文件大小都为零,除了kcore, mountsself

/root: 管理员目录

系统管理员的家目录,'root'。这可能会有点令人困惑,('根目录下的/root目录)但从历史上来讲,'/'是用户root的家目录(因此系统管理员的账号名叫root)。为保持规整,给用户'root'分配了一个家目录。但为什么不在'/home'中?因为'/home'经常位于不同的分区或者甚至在另一个系统上,因此当由于某些原因只挂载了'/'目录时,'/home'对于用户'root'可能是不可访问的。

/run: 短暂的运行时数据

The /run mountpoint is supposed to be a tmpfs mounted during early boot, available and writable to for all tools at any time during bootup. systemd, udev or mdadm that are required early in the boot process require this directory, because /var can be implemented as a separate file system to be mounted at a later stage in the start-up process. It replaces /var/run/, which becomes a symlink of /run.

/sbin: 系统二进制文件

Traditionally UNIX discriminates between 'normal' executables and those used for system maintenance and/or administrative tasks. The latter were supposed to reside either here or - the less important ones - in /usr/sbin. Programs executed after /usr is known to be mounted (when there are no problems) are generally placed into /usr/sbin. This directory contains binaries that are essential to the working of the system. These include system administration as well as maintenance and hardware configuration programs. GRUB (the command), fdisk, init, route, ifconfig, etc., all reside here. In practice, programs in /sbin require /usr to be mounted as all the necessary libraries are in /usr/lib. In the future the Arch devs intend to merge /sbin into /usr/bin.

/srv: 服务数据

Site-specific data which is served by the system. The main purpose of specifying this is so that users may find the location of the data files for a particular service, and so that services which require a single tree for read-only data, writable data and scripts (such as CGI scripts) can be reasonably placed. Data of interest to a specific user shall be placed in that user's home directory.

/tmp: 临时文件

This directory contains files that are required temporarily. Many programs use this to create lock files and for temporary storage of data. Do not remove files from this directory unless you know exactly what you are doing! Many of these files are important for currently running programs and deleting them may result in a system crash. On most systems, old files in this directory are cleared out at boot or at daily intervals.

/usr: 共享只读数据

While root is the primary filesystem, /usr is the secondary hierarchy, for user data, containing the majority of (multi-)user utilities and applications. /usr is shareable, read-only data. This means that /usr shall be shareable between various hosts and must not be written to, except by the package manager (installation, update, upgrade). Any information that is host-specific or varies with time is stored elsewhere.

Aside from /home/, /usr/ usually contains by far the largest share of data on a system. Hence, this is one of the most important directories in the system as it contains all the user binaries, their documentation, libraries, header files, etc. X and its supporting libraries can be found here. User programs like telnet, ftp, etc., are also placed here. In the original UNIX implementations, /usr/ (for user), was where the home directories of the system's users were placed (that is to say, /usr/someone was then the directory now known as /home/someone). Over time, /usr/ has become where userspace programs and data (as opposed to 'kernelspace' programs and data) reside. The name has not changed, but its meaning has narrowed and lengthened from everything user related to user usable programs and data. As such, the backronym 'User System Resources' was created.

/usr/bin: 二进制文件

Command binaries. This directory contains the vast majority of binaries (applications) on your system. Executables in this directory vary widely. For instance vi, gcc, and gnome-session reside here. Traditionally, this contained only binaries that did not require root privileges and that were not necessary in single-user mode. However, this is no longer enforced and the Arch devs plan to move all binaries here.

/usr/include: 头文件

编译用户空间源代码需要的头文件。

/usr/lib: 库

Note: The /lib directory becomes a symlink to /usr/lib. Here is the news. If you encounter error during this update. Please see DeveloperWiki:usrlib for solution.

Contains application private data (kernel modules, systemd services, udev rules, etc) and shared library images (the C programming code library). Libraries are collections of frequently used program routines and are readily identifiable through their filename extension of *.so. They are essential for basic system functionality. Kernel modules (drivers) are in the subdirectory /lib/modules/<kernel-version>.

/usr/sbin: 系统二进制文件

Non-essential system binaries of use to the system administrator. This is where the network daemons for the system reside, along with other binaries that (generally) only the system administrator has access to, but which are not required for system maintenance and repair. The Arch devs plan to move all the binaries from /usr/sbin to /usr/bin.

/usr/share: 架构相关数据

This directory contains 'shareable', architecture-independent files (docs, icons, fonts etc). Note, however, that '/usr/share' is generally not intended to be shared by different operating systems or by different releases of the same operating system. Any program or package which contains or requires data that do not need to be modified should store these data in '/usr/share/' (or '/usr/local/share/', if manually installed - see below). It is recommended that a subdirectory be used in /usr/share for this purpose.

/usr/src: 源代码

'linux'子目录下保存了Linux内核源代码和头文件。

/usr/local: 本地层次

Optional tertiary hierarchy for local data. The original idea behind '/usr/local' was to have a separate ('local') '/usr/' directory on every machine besides '/usr/', which might be mounted read-only from somewhere else. It copies the structure of '/usr/'. These days, '/usr/local/' is widely regarded as a good place in which to keep self-compiled or third-party programs. This directory is empty by default in Arch Linux. It may be used for manually compiled software installations if desired. pacman installs to /usr/, therefore, manually compiled/installed software installed to /usr/local/ may peacefully co-exist with pacman-tracked system software.

/var: 可变文件

Variable files, such as logs, spool files, and temporary e-mail files. On Arch, the ABS tree and pacman cache also reside here. Why not put the variable and transient data into /usr/? Because there might be circumstances when /usr/ is mounted as read-only, e.g. if it is on a CD or on another computer. '/var/' contains variable data, i.e. files and directories the system must be able to write to during operation, whereas /usr/ shall only contain static data. Some directories can be put onto separate partitions or systems, e.g. for easier backups, due to network topology or security concerns. Other directories have to be on the root partition, because they are vital for the boot process. 'Mountable' directories are: '/home', '/mnt', '/tmp', '/usr' and '/var'. Essential for booting are: '/bin', '/boot', '/dev', '/etc', '/lib', '/proc' and '/sbin'.

/var/abs

ABS树。一个类似于ports包含构建脚本的包管理系统,该目录包含带所有可安装的Arch软件相应子目录。

/var/cache/pacman/pkg

pacman包缓存。

/var/lib: 状态信息

程序运行时修改的永久数据(如数据库,包管理系统元数据等)。

/var/log: 日志文件

日志文件。

/var/mail: 用户邮件

用户邮箱目录,可共享。

/var/spool: 队列

等待被执行的任务的管道(如打印队列和未读邮件)。

/var/spool/mail

用户邮箱路径,已废弃.

/var/tmp: 可保存的临时文件

两次重启之间需要保存的文件。

另见