第 1 章. 文件系统结构
为什么分享公有的结构? (Why Share a Common Structure?)
操作系统的文件系统结构是它最基本组织的层次。 几乎一个操作系统同它的使用者,应用程序和安全模型交互的所有方法都依赖于它在一个存储设备上储存文件的方式。使用者和程序可以从一个通常的指引知道该在哪里读和写文件,有很多理由表明这是至关重要的。(It is crucial for a variety of reasons that users, as well as programs, be able to refer to a common guideline to know where to read and write files. )
一个文件系统从二种不同的角度来看,可分为:
可分享的和不可分享的文件(Shareable vs. unshareable files)
动态的和静态的文件(Variable vs. static files)
可分享的文件是那些以能被各种不同的主机访问;不可分享的文件不是对任何其他的主机都可访问。 动态文件能随时改变,不因为操作(Variable files can change at any time without any intervention);静态的文件(例如 只读的文档和二进制文件)不会改变,如果没有系统管理员或一个用户的一个操作。(static files, such as read-only documentation and binaries, do not change without an action from the system administrator or an agent that the system administrator has placed in motion to accomplish that task. )
这样看文件的理由是要帮助你了解给这些文件所在的目录的许可的类型。操作系统和它的使用者需要决定那些文件应该在哪里被放置,是否目录被设置成只读或可读写 , 和每个文件被允许访问的层次。这个组织的最高权限是决定性的,例如访问根目录可能被限制一样,否则 ,
权限是混乱的或不安全。(The top level of this organization is crucial, as the access to the underlying directories can be restricted or security problems may manifest themselves if the top level is left disorganized or without a widely-used structure )
然而, 只是有一个结构不意谓什么,除非它是一个标准。 竞争结构能实际上引起较他们为多的问题固定(Competing structures can actually cause more problems than they fix)。因为这,红帽子选择那最广泛地被使用了的文件系统结构,而且做了一些稍微的改变,使它适应在红帽子 Linux 里面被使用的特殊文件。
I. 系统叁考
目次
1. 文件系统结构
2. proc 文件系统
3. 启动程序, Init 和关机
4. 开机载入程序
5. 使用者和组
6. X 窗口系统
第十一帖
http://www.chinalinuxpub.com/doc/man...ystem-fhs.html
文件系统科学分类标准之概观 (FHS)( Overview of File System Hierarchy Standard (FHS))
红帽子遵守文件系统科学分类标准(FHS),一个定义许多文件和目录的名字和位置的协议。 我们将会继续遵守FHS( We will continue to track and follow the standard to keep Red Hat Linux FHS-compliant )
对任何符合FHS文件系统的系统来说,目前的 FHS 文件都是权威的叁考, 但是该标准在许多方面不明确或是可以深入探讨的。 在这一部分中,我们提供该标准的概观和不被该标准包含的文件系统的部份描述。
该标准的完全版本可在这里找到:
http://www.pathname.com/fhs
符合该标准意味着许多,但是最重要的两点是与其他符合该标准的系统保持兼容性和能够以只读的方式挂载/usr 部分(因为它包含一般的可运行的文件并且意谓着不能被使用者改变)。因为/usr 目录被以只读的方式挂载,它一从光盘被安装或从另外的一个机器经由被只能读的 NFS 安装。(Since the /usr directory is mounted read-only, it an be mounted from the CD-ROM or from another machine via a read-only NFS mount. )
FHS 组织
在这里提及的目录和文件是FHS 文件中的一小部分。查看最近的 FHS 文件,以获得更完全的信息。
/dev 目录
/dev 目录包含与系统有关的装置的说明文件(The /dev directory contains file system entries which represent devices that are attached to the system.)。 这些文件是系统进行适当操作的基础(These files are essential for the system to function properly。)
/etc 目录
/etc 目录是为安装到你机器上的配置文件而保留的。 没有二进制文件被放在 /etc 。从前被放在/etc的任何二进制文件现在应该放在 / sbin 或可能放在 /bin。
X11 和 skel 目录是/ etc 目录的子目录:
/etc
|- X11
|- skel
X11 目录是X11 的配置文件,例如 XF86Config 文件。 skel 目录放置 "基本的" 使用者的文件,当一个使用者初次被创立的时候用来使用的一个起始点目录(The skel directory is for "skeleton" user files, which are used to populate a home directory when a user is first created。)
/lib 目录
/ lib 目录应该只包含那些运行/ bin 和 /sbin中的二进制文件所需要的库文件。在 root 文件系统里面, 这些共享的库文件对开机和运行指令是非常重要的。
/mnt 目录
/ mnt 目录是为暂时安装的文件系统准备的, 例如 光盘和软盘。
/opt 目录
/opt 目录给较大的, 静态的(static)应用软件软件包被储存提供一个区域。
因为软件要避免放置他们的软件包在系统各处(For packages that wish to avoid putting their files throughout the file system),/ opt 在那个软件包的目录之下,提供一个合乎逻辑的和可预期的组织系统。 这给系统管理员在一个特别的软件包里面知道每个文件的作用提供了方便。
举例来说,如果样本名叫sample的软件包装在/opt,那麽它的全部文件会被放置在目录/opt/sample里面,例如 二进制文件放在/opt/sample/bin和帮助文档放在/opt/sample/man里
包含许多不同的子软件包的大软件包, 每完成一个特别的任务,就会去 /opt里面 得到组织它本身的大软件包的标准化的方法(Large packages that encompass many different sub-packages, each of which accomplish a particular task)。这样,我们的sample软件包可能有不同的工具来进入 他们自己的子目录,例如 /opt/sample/tool1 和/opt/sample/tool2,他们都有的自己 bin , man 和其他相似的目录。
/proc 目录
/ proc 目录包含与内核联系的特别的 "文件"。(The /proc directory contains special "files" that either extract information from or send information to the kernel )
由於有大量的数据在里面和这个目录能用来与内核沟通许多方法,我们专门用一个整篇来介绍。 对於较多的信息,请见第 2 章.
/sbin 目录
/ sbin 目录仅能被 root 使用者使用。 / sbin 只是在启动和挂载/usr,系统恢复操作中用到。 FHS描述:
"/ sbin仅作为/bin的补充在开机时用到。在运行之后的任何事 / usr 被知道被发起 ( 当没有问题) 应该被放在/usr/sbin之内。本地系统管理员的二进制文件应该被放在/usr/local/sbin内。"("/sbin typically contains files essential for booting the system in addition to the binaries in /bin. Anything executed after /usr is known to be mounted (when there are no problems) should be placed in /usr/sbin. Local-only system administration binaries should be placed into /usr/local/sbin.")
至少,下面的程序应该是在 /sbin中:
arp, clock,
getty, halt,
init, fdisk,
fsck.*, grub,
ifconfig, lilo,
mkfs.*, mkswap,
reboot, route,
shutdown, swapoff,
swapon, update
/usr 目录
/usr 目录是用来放置能共享访问整个站点的文件(The /usr directory is for files that can be shared across a whole site)。 / usr 目录通常有它自己的结构,而且它应该是只读的。至少,下列各项目录应该是/usr的子目录:
/usr
|- bin
|- dict
|- doc
|- etc
|- games
|- include
|- kerberos
|- lib
|- libexec
|- local
|- sbin
|- share
|- src
|- tmp -> ../var/tmp
|- X11R6
bin 目录包含可运行的文件,dict 包含非 FHS的文档页,/etc包含整个系统的配置文件,/games是为游戏,/include包含 C 头文件, kerberos 包含二进制文件和更多Kerberos(much more for Kerberos),lib 包含链接文件和没被设计成能直接被使用者使用的脚本或 shell的库文件 。libexec 目录包含被其他的程序称为辅助程序的程序, sbin 包含系统管理员的二进制文件( 但那些不在 /sbin中),share 包含不是结构-特效药的文件(contains files that are not architecture-specific), src 是为源程序码, X11R6 是与 X 窗口系统有关的。 (红帽子 Linux 上的 XFree86)
/usr/local 目录
FHS 说:
" /usr/local是为系统管理员安装软件使用的。 当系统软件被升级的时候 , 它需要从被重写。 它可能作为 在一群主机之中可分享的程序和数据, 但是不在 /usr中。"("The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable among a group of hosts, but not found in /usr.")
/usr/ local的结构与/usr 目录是相似的。 它有下列各项子目录,作用与 /usr 目录中是相似的:
/usr/local
|- bin
|- doc
|- etc
|- games
|- include
|- lib
|- libexec
|- sbin
|- share
|- src
/var 目录
因为 FHS 要求挂载/usr 为只读,任何程序的日志文件或需要缠绕在线桥上或锁目录应该写在 /var 目录中(any programs that write log files or need spool or lock directories should write them to the /var directory)。 FHS 描述/ var 为:
"...变动数据文件。 这包括卷线桥目录和文件, 管理的和砍伐原木数据 , 和短暂的和暂时的文件。"("...variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.")
下面应该是目录 /var的子目录:
/var
|- account
|- arpwatch
|- cache
|- crash
|- db
|- empty
|- ftp
|- gdm
|- kerberos
|- lib
|- local
|- lock
|- log
|- mail -> spool/mail
|- mailman
|- named
|- nis
|- opt
|- preserve
|- run
+- spool
|- anacron
|- at
|- cron
|- fax
|- lpd
|- mail
|- mqueue
|- news
|- rwho
|- samba
|- slrnpull
|- squid
|- up2date
|- uucp
|- uucppublic
|- vbox
|- voice
|- tmp
|- tux
|- www
|- yp
系统日志例如 信息和 lastlog均会被写入 /var/log。 /var/lib/ rpm 目录包含 rpm 系统数据库。 闭锁文件(Lock files)在/var/lock, 通常在目录中为正在使用文件的程序的个别项目(usually in directories particular for the program using the file.)。 / var/spool目录为各种不同的系统有子目录储存数据文件的需要(The /var/spool directory has subdirectories for various systems that need to store data files.) 。
在红帽子 Linux 中的 /usr/ local
在红帽子 Linux 中, 有意的使用 /usr/ local 些微地不同於 FHS所 叙述。FHS 说/usr/local 应该是你储存软件,保证安全的地方,要与系统软件升级独立(The FHS says that /usr/local should be where you store software that is to remain safe from system software upgrades)。因为红帽子升级是安全的------使用 rpm 指令和图形化的软件包管理工具应用程序,你不 需要放他们在 /usr/local中来保护文件。 但是,我们推荐你使用 /usr/ local 来放置软件。
举例来说,你从NFS挂载有来自一部名为jake的主机的只读的/ usr。如果有一个软件包或程序你想要安装,但是你没有对jake的写权限,你应该安装它在usr/local之下。稍后,如果你可以使jake的系统管理员安装程序在/ usr,你就能在/usr/local中卸载它。