Overview of Linux File System Hierarchy Standard (FHS)

Raveena Ratan
7 min readMay 2, 2023

--

Red Hat is committed to the Filesystem Hierarchy Standard (FHS), a collaborative document that defines the names and locations of many files and directories.

The FHS document is the authoritative reference to any FHS-complaint 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 complaint systems and the ability to mount a /usr/ partition as read-only because it contains common executables and should not be changed by users. Since the /usr/ directory is mounted read-only, it can be mounted from the CD-ROM or another machine via a read-only NFS mount.

FHS Organization

The directories and files noted here are a small subset of those specified by the FHS document.

The /dev/ Directory

The /dev/ directory contains file system entries that represent devices that are attached to the system. These files are essential for the system to function properly.

The /etc/ Directory

The /etc/ directory is reserved for configuration files that are local to the machine. No binaries are to be put in /etc/. Any binaries that were once located in /etc/ should be placed into /sbin/ or possibly /bin/.

The X11/and skel/ directories are subdirectories of the /etc/ directory:

/etc

|-X11/

|-skel/

The /etc/X11/ directory is for X11 configuration files such as XF86Config. The /etc/skel/ directory is for “skeleton” user files, which are used to populate a home directory when a user is first created.

The /lib/ Directory

The /lib/ directory should contain only those libraries that are needed to execute the binaries in /bin/ and /sbin/. These shared library images are particularly important for booting the system and executing commands within the root file system.

The /mnt/ Directory

The /mnt/ directory is for temporarily mounted file systems, such as CD-ROMs and floppy disks.

The /opt/ Directory

The /opt/ directory provides storage for large, static 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 the sample is the name of a particular software package located within the /opt/ directory, then all of its files could be placed within directories inside the /opt/sample/ directory, such as /opt/sample/bin/ for binaries and /opt/sample/man/ for manual pages.

Large packages that encompass many different sub-packages, each of which accomplishes a particular task, also go within the /opt/ directory, giving that large package a standardized way to organize itself. In this way, our sample package may have different tools that each go in their subdirectories, such as /opt/sample/tool1/ and /opt/sample/tool2/, each of which can have their own bin/, man/, and other similar directories.

The /proc/Directory

The /proc/ directory contains special files that either extract information from or send information to the kernel. 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.

The /sbin/ Directory

The /sbin/ Directory is for executables used only by the root user. The executables in /sbin/ are only used to boot and mount /usr/ and perform system recovery operations. The FHS says:

/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.”

At a minimum, the following problems should be in /sbin/:

arp, clock,

getty, halt,

init, fdisk,

fsck.*, grub,

ifconfig, lilo,

mkfs.*, mkswap,

reboot, route,

shutdown, swapoff,

swapon, update

The /usr/ Directory

The /usr/ directory is for files that can be shared across a whole site. The /usr/ directory usually has its partition, and it should be mountable and read-only. At a minimum, the following directories should be subdirectories of /usr/:

/usr

|-bin/

|-dict/

|-doc/

|-etc/

|-games/

|-include/

|-kerberos/

|-lib/

|-libexec/

|-local/

|-sbin/

|-share/

|-src/

|-tmp -> ../var/tmp/

|-X11R6/

The bin/ directories contain executables, dict/ contains non-FHS complaint documentation pages, etc/ contains system-wide configuration files, games is for games, include/ contains C header files, kerberos/ contains binaries and much more for Kerberos, and lib/ contains objects 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 /sbin/ directory), share/ contains files that are not architecture-specific, src/ is for source code, and X11R6/ is for the X Window System (XFree86 on Red Hat Linux).

The /usr/local/ Directory

The FHS says: “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 sharable among groups of hosts, but not found in /usr”.

The /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/ directory:

/usr/local

|-bin/

|-doc/

|-etc/

|-games/

|-include/

|-lib/

|-libexec/

|-sbin/

|-share/

|-src/

The /var/ Directory

Since the FHS requires Linux to mount /usr/ read-only, any programs that write log files or need spool/ or lock/ directories should write them to the /var/ directory. The FHS states /var/ is for:” …variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.”

Below are some of the directories which should be subdirectories of the /var/ directory:

/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/

|-lpd/

|-mail/

|-mqueue/

|-rwho/

|-samba/

|-squid/

|-tmp/

|-yp/

System log files such as messages/ and lastlog/ go into the /var/log/ directory. The /var/lib/rpm/ directory also contains the RPM system databases. Lock files go in the /var/lock/ directory, usually in directories particular for the program using the file. The /var/spool/ directory has subdirectories for various systems that need to store data files.

/usr/local/ in Red Hat Linux

In Red Hand 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 the system software upgrades is stored. Since system upgrades from under Red Hat Linux are performed safely with the rpm command and graphical Package Management Tool application, 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 /usr/local/ directory.

Special File Locations

Red Hat Linux extends the FHS structure slightly to accommodate special files. Most files about the Red Hat Package Manager (RPM) are kept in the /var/lib/rpm/ directory.

The /var/spool/up2date/ directory contains files used by Red Hat Update Agent, including RPM header information for the system. This location may also be used to temporarily store RPMs downloaded while updating the system.

Another location specific to Red Hat Linux is the /etc/sysconfig/ directory. This directory stores a variety of configuration information. Many scripts that run at boot time use the files in this directory.

Finally, one more directory worth noting is the /initrd/ directory. It is empty but is used as a critical mount point during the boot process.

The sysconfig Directory

The /etc/sysconfig/ directory is where a variety of system configuration files for Red Hat Linux are stored. Here we will outline some of the files found in the /etc/sysconfig/ directory. The information here is not intended to be complete, as many of these files have a variety of options that are only used in very specific or rare circumstances.

Files in the /etc/sysconfig/ Directory

The following files are normally found in the /etc/sysconfig/ directory:

|-amd

|-apmd

|-arpwatch

|-authconfig

|-cipe

|-clock

|-desktop

|-dhcpd

|-firstboot

|-gpm

|-harddisks

|-hwconf

|-il8n

|-identd

|-init

|-ipchains

|-iptables

|-irds

|-keyboard

|-kudzu

|-mouse

|-named

|-netdump

|-network

|-ntpd

|-pcmcia

|-radvd

|-rawdevices

|-redhat-config-securitylevel

|-redhat-config-users

|-redhat-logviewer

|-samba

|-sendmail

|-soundcard

|-spamassassin

|-squid

|-tux

|-ups

|-vncservers

|-xinetd

Note: If some of the files listed are not present in the /etc/sysconfig/ directory, then the corresponding program may not be installed.

Also, refer to further details

Introduction to Linux:

Linux Account Management:

The Linux Distribution Comparison:

--

--

Raveena Ratan

GₒₒD ₘₑₘₒᵣᵢₑₛ ₕᵤᵣₜ Yₒᵤ ₘₒᵣₑ ₜₕₑₙ BₐD ₘₑₘₒᵣᵢₑₛ ᵢₙ ₑₙₑₘᵢₜY..♥