Skip to main content
RunBook Academy

LinuxI · FoundationsFilesystem hierarchy

The Filesystem Hierarchy Standard

Foundation⏱ ~10 min🧪 Lab requiredbashlsfindstatcat

What you'll learn

  • Name the role of every top-level directory defined by the FHS
  • Distinguish /usr vs /etc vs /var vs /opt in storage decisions
  • Locate a binary, its configuration, and its logs without documentation
  • Recognise when a directory is tmpfs-backed, persistent, or shared

Prerequisites

None — start here.

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

The Filesystem Hierarchy Standard (FHS) is the agreement that decides what goes in /usr, what goes in /etc, what goes in /var, and what goes in /opt. The agreement is informal — no Linux distribution is FHS-certified — but every distribution follows it closely enough that you can move between them without relearning where things live.

The layout

flowchart TB
  ROOT["/ (root)"]

  ROOT --> BOOT["/boot<br/>kernel, initramfs, bootloader"]
  ROOT --> BIN["/bin<br/>essential user binaries"]
  ROOT --> SBIN["/sbin<br/>essential system binaries"]
  ROOT --> LIB["/lib<br/>shared libraries"]
  ROOT --> ETC["/etc<br/>host configuration"]
  ROOT --> HOME["/home<br/>user home directories"]
  ROOT --> ROOTDIR["/root<br/>root\'s home"]
  ROOT --> OPT["/opt<br/>add-on software"]
  ROOT --> USR["/usr<br/>userland (bin, lib, sbin, share, local)"]
  ROOT --> VAR["/var<br/>variable data (logs, caches, spool)"]
  ROOT --> RUN["/run<br/>runtime data (sockets, PIDs)"]
  ROOT --> PROC["/proc<br/>kernel + process info"]
  ROOT --> SYS["/sys<br/>device + driver info"]
  ROOT --> DEV["/dev<br/>device files"]
  ROOT --> TMP["/tmp<br/>temporary files"]
  ROOT --> SRV["/srv<br/>data served by the system"]
  ROOT --> MNT["/mnt and /media<br/>transient mount points"]

What every directory is for

The short version, with production framing. The FHS reference (linked above) has the long version.

DirectoryPurposePersistenceNotes
/Root of the tree. Mounted from the root filesystem.PersistentKeep small; only directories that must be available at boot belong here.
/bootKernel, initramfs, GRUB config.PersistentOften a separate partition so that encrypted root filesystems can still boot.
/bin, /sbinEssential binaries needed before /usr is mounted.PersistentOn modern systemd systems these are symlinks into /usr.
/libShared libraries for /bin and /sbin.PersistentSymlink into /usr/lib on modern systems.
/etcHost configuration files.Persistent“Editable text configuration” — every distribution uses this.
/homeRegular users’ home directories.PersistentOften a separate filesystem so user data survives OS reinstalls.
/rootroot user’s home directory.PersistentLives at /root, not under /home, so it remains available when /home is not mounted.
/optAdd-on software installed outside the package manager.PersistentVendor packages that should not pollute /usr — commercial applications, large third-party suites.
/usrUserland — the bulk of the operating system.PersistentMostly read-only in production.
/varVariable data: logs, caches, spool, databases.PersistentThe “stuff that grows” lives here. This is where disk-full incidents happen.
/runRuntime data since boot: process IDs, sockets, lockfiles.tmpfsCleared on reboot. systemd manages it.
/procKernel and process information as files.PseudoImplemented by the kernel.
/sysDevice, driver, and kernel subsystem information.Pseudosysfs.
/devDevice nodes and virtual device files.Pseudoudev manages it.
/tmpTemporary files.Distribution-dependenttmpfs on Fedora and Ubuntu 24.10+; a plain directory on the root filesystem on Debian 12, Ubuntu 24.04 LTS and RHEL 9. Check with findmnt /tmp. Where it is not tmpfs it eats root-filesystem space and is cleaned by age (systemd-tmpfiles, 10 days), not by reboot.
/srvData served by system services.PersistentConvention; many distributions barely use it.
/mnt, /mediaMount points for transient filesystems.Mount external drives here.

/usr — the bulk of the operating system

/usr is large, mounted early in boot, and should be treated as read-only in production. The interesting subdirectories:

  • /usr/bin — user commands. Every binary you can exec lives here.
  • /usr/sbin — system commands. The historical distinction (“sbin = system binaries”) has eroded; in practice, /usr/sbin contains commands intended for root and /usr/bin contains commands for everyone.
  • /usr/lib — libraries for /usr/bin and /usr/sbin.
  • /usr/share — architecture-independent data: man pages, locale files, icons.
  • /usr/local — locally-installed software that bypasses the package manager. Sysadmins use /usr/local for tools installed from source or for vendor scripts.
  • /usr/include — C headers (developer concern).
Read-only / Safeinspect top-level dirs
$ ls -ld /usr /var /etc /run /tmp
drwxr-xr-x  13 root root  4096 Jul 19 09:18 /usr
drwxr-xr-x  10 root root  4096 Aug  8 22:54 /var
drwxr-xr-x 120 root root  12288 Aug  9 10:01 /etc
drwxr-xr-x  28 root root   780 Aug  9 12:30 /run
drwxrwxrwt  15 root root   480 Aug  9 12:30 /tmp

/var — where disk-full incidents live

/var is where variable data lives. In production, the most common disk-full incidents come from:

  • /var/log — log files filling the disk because rotation is broken or undersized.
  • /var/cache — package manager caches (apt, dnf) growing unbounded.
  • /var/lib — state for installed services: databases, container storage, package database, machine-id.
  • /var/tmp — temporary files that are meant to survive reboot, and are aged out after 30 days rather than 10. Do not assume the converse for /tmp: it only vanishes at reboot where the distribution mounts it as tmpfs.
  • /var/spool — mail queues, print queues, cron spool.

/etc — the host configuration

/etc is small, text, and authoritative. Every daemon reads its configuration from somewhere under /etc. A few important conventions:

  • /etc/passwd, /etc/shadow, /etc/group — identity databases.
  • /etc/sudoers, /etc/sudoers.d/ — privilege escalation.
  • /etc/ssh/ — OpenSSH server and client configuration.
  • /etc/systemd/ — systemd configuration overrides.
  • /etc/fstab — filesystems mounted at boot.
  • /etc/hosts, /etc/resolv.conf, /etc/nsswitch.conf — name resolution.
  • /etc/chrony/chrony.conf or /etc/ntp.conf — time synchronisation.

Locating a binary, its config, and its logs

The three things every sysadmin needs to find for every service:

  1. Find the binary: which, command -v, type, or dpkg -L <pkg> / rpm -ql <pkg> to see all files installed by the package
  2. Find the configuration: dpkg -L <pkg> or rpm -qc <pkg> lists config files. For ad-hoc discovery, grep -r "Include" /etc/<daemon>/ and look for Include directives
  3. Find the logs. journalctl -u SERVICE is the systemd-native path. For traditional syslog, check /var/log/SERVICE and /etc/logrotate.d/SERVICE
  4. Find the unit file (systemd). systemctl cat SERVICE shows the active unit file including drop-in overrides
Read-only / Safesshd package contents
$ dpkg -L openssh-server | grep -E 'bin/|etc/.*ssh'
/usr/sbin/sshd
/etc/ssh/sshd_config
/etc/ssh/ssh_config.d
/etc/init.d/ssh

WhyThisMatters

Knowledge check

Knowledge check · 3 questions

  1. Q1. Which directory is the canonical home for log files on Linux?

  2. Q2. Files under /run persist across reboots on most modern Linux distributions.

  3. Q3. Which of the following directories are typically backed by pseudo-filesystems implemented by the kernel? Select all that apply.

Passing score: 75%. Answers are checked in this browser.