The Filesystem Hierarchy Standard

One of the biggest challenges facing portable software is the wide variation in filesystem layout across different operating systems. Each operating system has its own conventions and standards, making it difficult for developers to write software that can run on multiple platforms without modification.

In the case of Linux, the situation was particularly complicated due to the large number of distributions, each with its own unique filesystem layout. This led to the development of the Filesystem Hierarchy Standard (FHS) by the Linux maintainers, which aimed to establish a standard directory structure for Linux systems.

The FHS was developed to resolve the problem of incompatible filesystem layouts and to make it easier for software developers to write applications that could be run on multiple Linux distributions. The standard has been widely adopted by many Linux distributions, and has also been partially or fully adopted by other operating systems.

Some of the operating systems that have adopted the FHS, either partially or in full, include FreeBSD, NetBSD, OpenBSD, Solaris, and macOS.

The FHS Directory Structure

The FHS specifies a standard directory structure for Linux systems, with the following top-level directory structure:

/bin

This directory contains essential user command binaries that must be available in single-user mode.

/boot

This directory contains files necessary to boot the system, including the kernel, initial ramdisk image, and bootloader configuration files.

/dev

This directory contains device files for all hardware devices connected to the system, including virtual devices.

/etc

This directory contains system configuration files that are specific to the local system.

/home

This directory contains home directories for all non-system users.

/lib

This directory contains shared libraries that are needed by the essential binaries in the /bin and /sbin directories.

/media

This directory contains mount points for removable media, such as USB drives and optical discs.

/mnt

This directory is used as a mount point for temporarily mounted filesystems.

/opt

This directory is used for installing optional software packages.

/proc

This directory contains a virtual filesystem that provides information about running processes and system resources.

/root

This directory contains the home directory for the root user.

/run

This directory contains runtime data that should be preserved between reboots.

/sbin

This directory contains essential system binaries that must be available in single-user mode.

/srv

This directory contains data for services provided by the system.

/sys

This directory contains a virtual filesystem that provides information about the system’s hardware devices and drivers.

/tmp

This directory contains temporary files that are deleted upon reboot.

/usr

This directory contains user binaries, libraries, and header files.

/var

This directory contains variable data files, such as log files and spool directories for printing and mail.