LinuxI · FoundationsFilesystem hierarchy
The Filesystem Hierarchy Standard
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
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.
| Directory | Purpose | Persistence | Notes |
|---|---|---|---|
/ | Root of the tree. Mounted from the root filesystem. | Persistent | Keep small; only directories that must be available at boot belong here. |
/boot | Kernel, initramfs, GRUB config. | Persistent | Often a separate partition so that encrypted root filesystems can still boot. |
/bin, /sbin | Essential binaries needed before /usr is mounted. | Persistent | On modern systemd systems these are symlinks into /usr. |
/lib | Shared libraries for /bin and /sbin. | Persistent | Symlink into /usr/lib on modern systems. |
/etc | Host configuration files. | Persistent | “Editable text configuration” — every distribution uses this. |
/home | Regular users’ home directories. | Persistent | Often a separate filesystem so user data survives OS reinstalls. |
/root | root user’s home directory. | Persistent | Lives at /root, not under /home, so it remains available when /home is not mounted. |
/opt | Add-on software installed outside the package manager. | Persistent | Vendor packages that should not pollute /usr — commercial applications, large third-party suites. |
/usr | Userland — the bulk of the operating system. | Persistent | Mostly read-only in production. |
/var | Variable data: logs, caches, spool, databases. | Persistent | The “stuff that grows” lives here. This is where disk-full incidents happen. |
/run | Runtime data since boot: process IDs, sockets, lockfiles. | tmpfs | Cleared on reboot. systemd manages it. |
| /proc | Kernel and process information as files. | Pseudo | Implemented by the kernel. |
/sys | Device, driver, and kernel subsystem information. | Pseudo | sysfs. |
/dev | Device nodes and virtual device files. | Pseudo | udev manages it. |
/tmp | Temporary files. | Distribution-dependent | tmpfs 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. |
/srv | Data served by system services. | Persistent | Convention; many distributions barely use it. |
/mnt, /media | Mount 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 canexeclives here./usr/sbin— system commands. The historical distinction (“sbin = system binaries”) has eroded; in practice,/usr/sbincontains commands intended for root and/usr/bincontains commands for everyone./usr/lib— libraries for/usr/binand/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/localfor tools installed from source or for vendor scripts./usr/include— C headers (developer concern).
$ ls -ld /usr /var /etc /run /tmpdrwxr-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.confor/etc/ntp.conf— time synchronisation.
Locating a binary, its config, and its logs
The three things every sysadmin needs to find for every service:
- Find the binary:
which,command -v,type, ordpkg -L <pkg>/rpm -ql <pkg>to see all files installed by the package - Find the configuration:
dpkg -L <pkg>orrpm -qc <pkg>lists config files. For ad-hoc discovery,grep -r "Include" /etc/<daemon>/and look forIncludedirectives - Find the logs. journalctl -u SERVICE is the systemd-native path. For traditional syslog, check /var/log/SERVICE and /etc/logrotate.d/SERVICE
- Find the unit file (systemd). systemctl cat SERVICE shows the active unit file including drop-in overrides
$ dpkg -L openssh-server | grep -E 'bin/|etc/.*ssh'/usr/sbin/sshd
/etc/ssh/sshd_config
/etc/ssh/ssh_config.d
/etc/init.d/sshWhyThisMatters
Knowledge check
Knowledge check · 3 questions
Q1. Which directory is the canonical home for log files on Linux?
Q2. Files under /run persist across reboots on most modern Linux distributions.
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.