The filesystem hierarchy
Why Linux puts files where it does: /usr for the OS, /etc for config, /var for state, /run for runtime, the merged /usr, and why /tmp is now often RAM.
What Linux is: the kernel and the distributionGetting a Linux machine to practice on
The filesystem hierarchy
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- The layout sorts files by how they behave: /usr holds the vendor's operating system and is normally read-only, /etc holds this machine's configuration, /var holds data that changes and must survive a reboot, /run holds data that must not.
- Modern distributions have merged /usr: /bin, /sbin and /lib are symlinks into /usr. Fedora 42 and later go one step further and make /usr/sbin a symlink to bin.
- /tmp is for small throwaway files and is increasingly a tmpfs in RAM (Debian 13 made that the default). Large or long-lived temporary files belong in /var/tmp.
- /opt and /srv are for software and data the distribution does not manage. /proc, /sys and /dev are not on disk at all: the kernel generates them.
- Knowing which directories hold state tells you what to back up: /etc, /var/lib, /srv and /home. /usr can be reinstalled from packages.
A map you can rely on
The devops lesson the Linux server from an operator’s seat gave the short version: config in /etc, logs in /var/log, programs in /usr. This lesson explains the reasoning, because the reasoning is what lets you guess correctly on a system you have never seen.
The core idea is that files are sorted by how they behave, not by which program they belong to. Nginx’s binary, its config and its logs live in three different trees. That looks messy until you ask the questions an administrator actually asks. Can this be shared between machines? Does it change while the system runs? Must it survive a reboot? Who is allowed to change it? Each top-level directory is one answer to those questions.
The vendor’s tree: /usr
/usr holds the operating system as the distribution shipped it: programs in /usr/bin, libraries in /usr/lib, documentation and data in /usr/share. The UAPI group’s Linux File System Hierarchy spec, the current successor to systemd’s file-hierarchy(7), calls it “vendor-supplied operating system resources”, usually read-only, and says it “should not be modified by the administrator, except when installing or removing vendor-supplied packages”.
That rule is what makes upgrades safe. The package manager owns /usr. If you hand-edit a file there, the next update overwrites it. Your own locally built software goes in /usr/local, which the package manager leaves alone.
The merged /usr
Historically /bin and /sbin held the programs needed to boot before /usr was mounted, and /usr/bin held everything else. That split has not been needed for years, since an initramfs can mount /usr early. So distributions merged them: /bin, /sbin and /lib became symlinks into /usr.
I checked the official container images of four distributions, downloaded with curl and unpacked on a Mac, using readlink:
| Path | Debian 13 | Ubuntu 24.04 | Fedora 45 | Alpine 3.24 |
|---|---|---|---|---|
/bin |
→ usr/bin |
→ usr/bin |
→ usr/bin |
real directory |
/sbin |
→ usr/sbin |
→ usr/sbin |
→ usr/sbin |
real directory |
/lib |
→ usr/lib |
→ usr/lib |
→ usr/lib |
real directory |
/usr/sbin |
real directory | real directory | → bin |
real directory |
/var/run |
→ /run |
→ /run |
→ ../run |
→ ../run |
Debian’s trixie release notes describe “the finalization of the usrmerge project”. Fedora went further in Fedora 42 by making /usr/sbin a symlink to bin, so on Fedora every system binary lives in one directory. Alpine has not merged at all. Scripts should therefore call /usr/bin/env or rely on PATH rather than hard-coding /sbin/something.
This machine’s files: /etc and /var
/etc holds configuration for this host. It is small: the whole Debian image has 93 files there, about 400 KB, against about 120 MB in /usr. Small, precious and edited by hand, so it is the first thing to keep in version control or a config management tool.
/var holds data that changes while the system runs and must survive a reboot. /var/lib is application state: package databases, a database server’s data directory. /var/log holds log files, /var/cache holds anything that can be regenerated and deleted safely, and /var/spool holds queued work like mail.
Runtime files: /run
/run is a tmpfs, a filesystem in memory, created fresh at every boot. PID files, sockets and lock files go here, because a stale PID file from before a crash is worse than none. The UAPI spec calls it “flushed on boot” and keeps /var/run only as a compatibility symlink to it, as the table shows.
Temporary files: /tmp and /var/tmp
/tmp is for small, short-lived files. The UAPI spec says it “is usually mounted as a tmpfs instance, and should hence not be used for larger files”, and points to /var/tmp for “larger and persistent temporary files”, which is on disk and survives reboots. Debian 13 made the tmpfs /tmp its default. Its release notes say /tmp is now stored in memory, sized by default to up to 50% of RAM, with the old behaviour available via systemctl mask tmp.mount. Scripts that unpack large archives into /tmp can now run a server out of memory. The safe temporary files lesson covers creating them safely with mktemp.
Everything else
/opt: self-contained third-party software. The UAPI spec now calls it optional and discourages it, but you will still find vendor agents installed there./srv: data a server publishes, such as web roots, laid out however the administrator likes./homeand/root: users’ home directories. Root’s is separate so the administrator can log in even if/homefails to mount./boot: kernels, initramfs images and bootloader files, covered in the boot group./dev,/proc,/sys: not on disk. The kernel generates them, and the udev and /proc and /sys lessons cover them.
About the video
The embed is That DevOps Guy’s “The Linux Filesystem Explained for Absolute Beginners”, September 2026, clipped from the “System Folders” chapter to the end (about 12 minutes). It skips the opening on moving around the filesystem with cd and ls, which the shell-bash roadmap covers. The clip walks bin, sbin, the symlinks of the merged /usr, usr, lib, etc, boot, home directories, var, tmp versus var/tmp, opt and srv, /dev, /proc, /sys, /run and /mnt, so it lines up closely with this lesson. I judged that from its chapters. It does not mention Fedora’s /usr/sbin merge or Debian’s tmpfs /tmp. English was judged from the title, channel and original English audio track. DorianDotSlash’s 2018 tour in deeper is the classic version but predates merged /usr on Ubuntu.
What was run: the readlink, du and file counts on the downloaded images. The rules are quoted from the UAPI.9 spec and Debian 13’s release notes; the Fedora 42 change is from Fedora’s change page as reported in search results. Checked 2026-11-28.
Check yourself
You need to back up a database server so it can be rebuilt. Which directories matter and which can be recreated from packages?
Back up /etc for configuration and /var/lib (plus /srv or /home if used) for data. /usr comes from packages and can be reinstalled.
A script writes a 20 GB scratch file to /tmp on Debian 13 and the machine starts swapping. Why, and where should the file go?
Debian 13 mounts /tmp as tmpfs by default, so the file lives in RAM. Large temporary files belong in /var/tmp, which is on disk.
On a merged-/usr system, is /bin/ls a different file from /usr/bin/ls?
No. /bin is a symlink to usr/bin, so both paths reach the same file.
Why does /run exist when /var/run used to do the same job?
Runtime files such as PID files and sockets must be wiped at boot and be available early, so they live on a tmpfs at /run. /var/run is kept only as a compatibility symlink to it.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.