1.2. Overview of File System Hierarchy Standard (FHS)
Red Hat Enterprise Linux uses the Filesystem Hierarchy Standard (FHS) file system structure, which defines the names, locations, and permissions for many file types and directories.
The FHS document is the authoritative reference to any FHS-compliant file system, but the standard leaves many areas undefined or extensible. This section is an overview of the standard and a description of the parts of the file system not covered by the standard.
Compliance with the standard means many things, but the two most important are compatibility with other compliant systems and the ability to mount a
/usr/partition as read-only. This second point is important because the directory contains common executables and should not be changed by users. Also, since the
/usr/directory is mounted as read-only, it can be mounted from the CD-ROM or from another machine via a read-only NFS mount.
1.2.1. FHS Organization
The directories and files noted here are a small subset of those specified by the FHS document. Refer to the latest FHS document for the most complete information.
The complete standard is available online at http://www.pathname.com/fhs/.
/boot/directory contains static files required to boot the system, such as the Linux kernel. These files are essential for the system to boot properly.
Do not remove the
/boot/directory. Doing so renders the system unbootable.
/dev/directory contains device nodes that either represent devices that are attached to the system or virtual devices that are provided by the kernel. These device nodes are essential for the system to function properly. The
udevdaemon takes care of creating and removing all these device nodes in
Devices in the
/devdirectory and subdirectories are either character (providing only a serial stream of input/output) or block (accessible randomly). Character devices include mouse, keyboard, modem while block devices include hard disk, floppy drive etc. If you have GNOME or KDE installed in your system, devices such as external drives or cds are automatically detected when connected (e.g via usb) or inserted (e.g via CD or DVD drive) and a popup window displaying the contents is automatically displayed. Files in the
/devdirectory are essential for the system to function properly.
Table 1.1. Examples of common files in the
|/dev/hda||The master device on primary IDE channel.|
|/dev/hdb||The slave device on primary IDE channel.|
|/dev/tty0||The first virtual console.|
|/dev/tty1||The second virtual console.|
|/dev/sda||The first device on primary SCSI or SATA channel.|
|/dev/lp0||The first parallel port.|
/etc/directory is reserved for configuration files that are local to the machine. No binaries are to be placed in
/etc/. Any binaries that were once located in
/etc/should be placed into
Examples of directories in
/etc |- X11/ |- skel/
/etc/X11/directory is for X Window System configuration files, such as
/etc/skel/directory is for "skeleton" user files, which are used to populate a home directory when a user is first created. Applications also store their configuration files in this directory and may reference them when they are executed.
/lib/directory should contain only those libraries needed to execute the binaries in
/sbin/. These shared library images are particularly important for booting the system and executing commands within the root file system.
/media/directory contains subdirectories used as mount points for removable media such as usb storage media, DVDs, CD-ROMs, and Zip disks.
/mnt/directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removable media, please use the
/media/directory. Automatically detected removable media will be mounted in the
/mntdirectory must not be used by installation programs.
/opt/directory provides storage for most application software packages.
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, giving the system administrator an easy way to determine the role of each file within a particular package.
For example, if
sampleis the name of a particular software package located within the
/opt/directory, then all of its files are placed in directories inside the
/opt/sample/directory, such as
/opt/sample/bin/for binaries and
/opt/sample/man/for manual pages.
Packages that encompass many different sub-packages, data files, extra fonts, clipart etc are also located in the
/opt/directory, giving that large package a way to organize itself. In this way, our
samplepackage may have different tools that each go in their own sub-directories, such as
/opt/sample/tool2/, each of which can have their own
man/, and other similar directories.
/proc/directory contains special files that either extract information from or send information to the kernel. Examples include system memory, cpu information, hardware configuration etc.
Due to the great variety of data available within
/proc/and the many ways this directory can be used to communicate with the kernel, an entire chapter has been devoted to the subject. For more information, refer to Chapter 5, The
/sbin/directory stores executables used by the root user. The executables in
/sbin/are used at boot time, for system administration and to perform system recovery operations. Of this directory, the FHS says:
/sbincontains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in
/bin. Programs executed after
/usr/is known to be mounted (when there are no problems) are generally placed into
/usr/sbin. Locally-installed system administration programs should be placed into
At a minimum, the following programs should be in
/srv/directory contains site-specific data served by your system running Red Hat Enterprise Linux. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the
/sys/directory utilizes the new
sysfsvirtual file system specific to the 2.6 kernel. With the increased support for hot plug hardware devices in the 2.6 kernel, the
/sys/directory contains information similarly held in
/proc/, but displays a hierarchical view of specific device information in regards to hot plug devices.
/usr/directory is for files that can be shared across multiple machines. The
/usr/directory is often on its own partition and is mounted read-only. At a minimum, the following directories should be subdirectories of
/usr |- bin/ |- etc/ |- games/ |- include/ |- kerberos/ |- lib/ |- libexec/ |- local/ |- sbin/ |- share/ |- src/ |- tmp -> ../var/tmp/
bin/subdirectory contains executables,
etc/contains system-wide configuration files,
gamesis for games,
include/contains C header files,
kerberos/contains binaries and other Kerberos-related files, and
lib/contains object files and libraries that are not designed to be directly utilized by users or shell scripts. The
libexec/directory contains small helper programs called by other programs,
sbin/is for system administration binaries (those that do not belong in the
share/contains files that are not architecture-specific,
src/is for source code.
The FHS says:
/usr/localhierarchy 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/local/directory is similar in structure to the
/usr/directory. It has the following subdirectories, which are similar in purpose to those in the
/usr/local |- bin/ |- etc/ |- games/ |- include/ |- lib/ |- libexec/ |- sbin/ |- share/ |- src/
In Red Hat Enterprise Linux, the intended use for the
/usr/local/directory is slightly different from that specified by the FHS. The FHS says that
/usr/local/should be where software that is to remain safe from system software upgrades is stored. Since software upgrades can be performed safely with RPM Package Manager (RPM), it is not necessary to protect files by putting them in
/usr/local/. Instead, the
/usr/local/directory is used for software that is local to the machine.
For instance, if the
/usr/directory is mounted as a read-only NFS share from a remote host, it is still possible to install a package or program under the
Since the FHS requires Linux to mount
/usr/as read-only, any programs that write log files or need
lock/directories should write them to the
/var/directory. The FHS states
...variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
Below are some of the directories found within the
/var |- account/ |- arpwatch/ |- cache/ |- crash/ |- db/ |- empty/ |- ftp/ |- gdm/ |- kerberos/ |- lib/ |- local/ |- lock/ |- log/ |- mail -> spool/mail/ |- mailman/ |- named/ |- nis/ |- opt/ |- preserve/ |- run/ +- spool/ |- at/ |- clientmqueue/ |- cron/ |- cups/ |- exim/ |- lpd/ |- mail/ |- mailman/ |- mqueue/ |- news/ |- postfix/ |- repackage/ |- rwho/ |- samba/ |- squid/ |- squirrelmail/ |- up2date/ |- uucp |- uucppublic/ |- vbox/ |- tmp/ |- tux/ |- www/ |- yp/
System log files, such as
lastlog, go in the
/var/lib/rpm/directory contains RPM system databases. Lock files go in the
/var/lock/directory, usually in directories for the program using the file. The
/var/spool/directory has subdirectories for programs in which data files are stored.