5.2. Overview of File System Hierarchy Standard (FHS)
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.
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 at https://www.pathname.com/fhs/
126.96.36.199. Gathering File System Information
df command reports the system's disk space usage. Its output looks similar to the following:
Filesystem 1K-blocks Used Available Use% Mounted on
11675568 6272120 4810348 57% / /dev/sda1
100691 9281 86211 10% /boot
none 322856 0 322856 0% /dev/shm
df shows the partition size in 1 kilobyte blocks and the amount of used/available disk space in kilobytes. To view the information in megabytes and gigabytes, use the command
df -h. The
-h argument stands for "human-readable" format. The output for
df -h looks similar to the following:
Filesystem Size Used Avail Use% Mounted on
12G 6.0G 4.6G 57% / /dev/sda1
99M 9.1M 85M 10% /boot
none 316M 0 316M 0% /dev/shm
The mounted partition
/dev/shm represents the system's virtual memory file system.
du command displays the estimated amount of space being used by files in a directory, displaying the disk usage of each subdirectory. The last line in the output of
du shows the total disk usage of the directory; to see only the total disk usage of a directory in human-readable format, use
du -hs. For more options, refer to
To view the system's partitions and disk space usage in a graphical format, use the Gnome System Monitor by clicking on > > or using the command
gnome-system-monitor. Select the File Systems tab to view the system's partitions. The figure below illustrates the File Systems tab.
Figure 5.1. GNOME System Monitor File Systems tab
/boot/ directory contains static files required to boot the system, e.g. 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 represent the following device types:
These device nodes are essential for the system to function properly. The
udevd daemon creates and removes device nodes in
/dev/ as needed.
Devices in the
/dev/ directory and subdirectories are either character (providing only a serial stream of input/output, e.g. mouse or keyboard) or block (accessible randomly, e.g. hard drive, floppy drive). If you have GNOME or KDE installed, some storage devices 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 appears.
Table 5.1. Examples of common files in the
||The master device on primary IDE channel.
||The slave device on primary IDE channel.
||The first virtual console.
||The second virtual console.
||The first device on primary SCSI or SATA channel.
||The first parallel port.
/etc/ directory is reserved for configuration files that are local to the machine. It should contain no binaries; any binaries should be moved to
For example, the
/etc/skel/ directory stores "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 executed. The
/etc/exports file controls which file systems to export to remote hosts.
/lib/ directory should only contain libraries needed to execute the binaries in
/sbin/. These shared library images are used to boot the system or execute commands within the root file system.
/mnt/ directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removeable storage media, use the
/media/ directory. Automatically detected removeable media will be mounted in the
/mnt directory must not be used by installation programs.
/opt/ directory is normally reserved for software and add-on packages that are not part of the default installation. A package that installs to
/opt/ creates a directory bearing its name, e.g.
/opt/. In most cases, such packages follow a predictable subdirectory structure; most store their binaries in
/opt/ and their
man pages in
/opt/, and so on.
directory contains special files that either extract information from the kernel or send information to it. Examples of such information include system memory, cpu information, and hardware configuration. For more information about
, refer to Section 5.4, “The /proc Virtual File System”
/sbin/ directory stores binaries essential for booting, restoring, recovering, or repairing the system. The binaries in
/sbin/ require root privileges to use. In addition,
/sbin/ contains binaries used by the system before the
/usr/ directory is mounted; any system utilities used after
/usr/ is mounted is typically placed in
At a minimum, the following programs should be stored in
/srv/ directory contains site-specific data served by a Red Hat Enterprise Linux system. 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
sysfs virtual 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 similar to that held by
/proc/, but displays a hierarchical view device information specific 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,
/usr/ should contain the following subdirectories:
/usr/bin, used for binaries
/usr/etc, used for system-wide configuration files
/usr/include, used for C header files
/usr/kerberos, used for Kerberos-related binaries and files
/usr/lib, used for object files and libraries that are not designed to be directly utilized by shell scripts or users
/usr/libexec, contains small helper programs called by other programs
/usr/sbin, stores system administration binaries that do not belong to
/usr/share, stores files that are not architecture-specific
/usr/src, stores source code
/usr/ directory should also contain a
/local/ subdirectory. As per the FHS, this subdirectory is used by the system administrator when installing software locally, and should be safe from being overwritten during system updates. The
/usr/local directory has a structure similar to
/usr/, and contains the following subdirectories:
Red Hat Enterprise Linux's usage of
/usr/local/ differs slightly from the FHS. The FHS states that
/usr/local/ should be used to store software that should remain safe from system software upgrades. Since the RPM Package Manager can perform software upgrades safely, it is not necessary to protect files by storing them in
Instead, Red Hat Enterprise Linux uses
/usr/local/ for software 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
/var/ is for variable data files, which include spool directories/files, logging data, transient/temporary files, and the like.
Below are some of the directories found within the
System log files, such as
lastlog, go in the
/var/log/ directory. 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 that store data files for some programs. These subdirectories include: