The Linux Filesystem Hierarchy Standard (FHS) is less about organizing files and more about defining expectations for where specific types of programs and data should live, enabling users and package managers to find things reliably across different Linux distributions.

Let’s see it in action. Imagine you’re trying to find the configuration file for the SSH server. You know it’s a system configuration, so you’d naturally look in /etc.

$ ls /etc/ssh/sshd_config
/etc/ssh/sshd_config

Here’s sshd_config, right where you’d expect it. Now, let’s say you need to find the actual executable for the ls command. That’s a binary program, and by convention, those live in /bin or /usr/bin.

$ which ls
/usr/bin/ls

The FHS dictates these locations. It’s a set of rules that says, "System binaries go here," "User-specific configuration goes there," and so on. This standardization is crucial because it means you don’t have to learn a new directory structure for every Linux distro you encounter. A user’s home directory will always be /home/username, system-wide configuration will always be in /etc, and temporary files will be in /tmp.

The FHS aims to bring order to the seemingly chaotic world of Unix-like file systems. It defines the main directories and their contents, ensuring consistency and predictability. This allows applications to be installed and run without needing to know the specifics of every single system.

Here’s a breakdown of the most common top-level directories:

  • /: The root directory. Everything on the system starts here.
  • /bin: Essential user command binaries. These are commands needed in single-user mode (e.g., ls, cp, mv, bash).
  • /sbin: Essential system binaries. These are commands used by the system administrator for system maintenance (e.g., fdisk, init, mount).
  • /etc: Host-specific system configuration files. This is where most configuration files reside, typically in plain text.
  • /dev: Device files. These represent hardware devices, like disks (/dev/sda), terminals (/dev/tty0), and other peripherals.
  • /proc: Virtual filesystem providing process and kernel information. Files here aren’t stored on disk but are dynamically generated by the kernel.
  • /var: Variable data files. This includes things like log files (/var/log), spool directories for mail and print jobs (/var/spool), and temporary files that need to persist across reboots (/var/tmp).
  • /usr: Secondary hierarchy for read-only user data. This is where most user applications and utilities reside, including /usr/bin (non-essential binaries), /usr/sbin (non-essential system binaries), /usr/lib (libraries for /usr/bin), and /usr/share (architecture-independent data).
  • /home: User home directories. Each user typically has a subdirectory here (e.g., /home/alice, /home/bob).
  • /boot: Static files of the boot loader. This directory contains the kernel and other files needed to start the system.
  • /lib: Essential shared libraries and kernel modules. Libraries needed by binaries in /bin and /sbin.
  • /opt: Optional application software packages. Used for installing software that doesn’t fit the standard hierarchy.
  • /mnt: Mount point for temporarily mounted filesystems.
  • /media: Mount points for removable media, like CD-ROMs and USB drives.
  • /srv: Data for services provided by the system. For example, data for web servers might be in /srv/www.
  • /tmp: Temporary files. Files here are expected to be deleted on reboot.

The distinction between /bin and /usr/bin, or /sbin and /usr/sbin, is a historical one. Originally, /bin and /sbin were for binaries that must be present for the system to boot and operate in single-user mode. /usr/bin and /usr/sbin were for the bulk of user-installed programs. On modern systems, especially those that might be booted from read-only media, the line can blur, and /usr is often a separate partition.

One of the most subtle but powerful aspects of the FHS is how it separates executables from their data and libraries. For instance, the executables in /usr/bin will find their associated libraries in /usr/lib or /usr/lib64 (depending on architecture), and their architecture-independent data files in /usr/share. This separation allows for cleaner system management and easier upgrades. A common misconception is that /var is just for logs, but its role extends to any data that changes during system operation, including caches, spool files, and temporary data that needs to survive reboots, which is why /var/tmp exists separately from /tmp.

Understanding the FHS is fundamental to navigating and managing any Linux system effectively. The next step is often understanding how these directories are managed by package managers and how to override or extend these conventions for custom applications.

Want structured learning?

Take the full Linux & Systems Programming course →