Main directories
| path | what is inside |
|---|---|
/ | the root of everything; whatever does not fit the subdirectories below |
/bin, /sbin, /usr/bin, /usr/sbin | executable binaries (/usr/* is now unified with /) |
/lib, /usr/lib | shared libraries and kernel modules (/lib/modules/) |
/etc | configuration. Text-based, read-only for applications by convention |
/var | data that changes on a running system: logs, queues, databases, caches |
/var/log | service logs |
/var/lib/<pkg> | persistent application state (postgres data, docker layers) |
/var/run -> /run | runtime state (PID files, UNIX sockets), tmpfs, gone on reboot |
/usr | read-only distro data: /usr/bin, /usr/lib, /usr/share, /usr/local |
/usr/local | same as /usr but for software installed locally (outside the package manager) |
/home/<user> | user directories |
/root | root's home (kept apart from /home so root does not get stuck when /home is unmounted) |
/tmp | temporary files; usually cleared on reboot, sometimes tmpfs |
/proc | virtual FS that is an interface to the kernel and processes: /proc/self/, /proc/cpuinfo, /proc/sys/* |
/sys | same for devices, buses, cgroups, drivers (/sys/fs/cgroup, /sys/class/net) |
/dev | devices: /dev/null, /dev/zero, /dev/sda, /dev/pts/* |
/boot | kernel, initramfs, GRUB |
/opt | optional third-party packages that do not follow FHS (often vendor packages) |
/srv | service data: content for a website, ftp, and so on |
/mnt, /media | mount points for removable media and one-off mounts |
The logic behind splitting /usr vs /var vs /etc
The split is not arbitrary. It gives you three different backup strategies:
/usrreinstalls from the repositories (you do not have to back it up)/etcis small, text-based, and must be backed up/varis large changing data, so you need an FS snapshot or a dump
Systems that break FHS
- NixOS keeps everything in
/nix/store/<hash>-name/, FHS is not used - Container images usually follow FHS, but with their "own" FS inside the container
- macOS is POSIX, but adds
/Applications,/System,/Users - Snap/Flatpak packages live in their own namespaces, seen as a normal FHS from inside