The Linux Filesystem & Directory Hierarchy
Everything in Linux lives in one tree rooted at /. Learn the Filesystem Hierarchy Standard — what /etc, /var, /usr, /home and the rest are for, why /bin is a symlink, and how virtual filesystems like /proc and /sys let you troubleshoot a live system.
What is this?
The Linux filesystem is a single tree rooted at / (the root directory). The Filesystem Hierarchy Standard (FHS) defines what most of those top-level directories are for, so /etc always holds configuration, /var holds logs and caches, /usr holds programs, and /home holds user data. Two of the branches, /proc and /sys, are not real disks at all — they are virtual views into the running kernel and hardware, which is exactly why they are so powerful for troubleshooting.
Why do you need it?
- Every mainstream distribution follows the FHS, so knowing /etc, /var and /usr transfers to Ubuntu, RHEL and even Alpine containers.
- Logs, configs and binaries live in predictable places, so you can start debugging a server you have never seen before without reading a README.
- /proc and /sys expose kernel and hardware state as plain files — no special tools required, just cat and ls.
- Knowing what is volatile (/tmp, /run) versus persistent (/etc, /home) prevents embarrassing and costly data-loss mistakes.
- Interviewers ask FHS questions to test real hands-on experience rather than memorised flags.
Mental model
A city zoned into districts
The Linux filesystem
A city zones residential, commercial and administrative areas so you always know where to find things. The FHS zones the Linux tree the same way — /etc is the council office (config), /var is the records archive (logs), /home is the housing (users), and /proc is the live traffic camera feed (kernel state).
How it works
- At boot the kernel mounts the root filesystem at / and every other filesystem is attached beneath it at a mount point.
- The FHS assigns each top-level directory a fixed role: binaries, config, logs, user data, temporary data.
- Distributions use symlinks like /bin -> /usr/bin so legacy paths keep working after the merged /usr layout.
- /proc and /sys generate files on demand from live kernel structures and hardware state.
- Tools like df, mount and du read the mount table and block devices so you can see exactly what uses space and which device backs each path.
One tree, many roles: where things live in an FHS-compliant system.
Key commands
ls /List the top-level directories defined by the FHS.
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
ls -ld /varShow the permissions, owner and type of /var itself.
drwxr-xr-x 13 root root 4096 Aug 8 09:14 /var
readlink /binPrint where the symlink /bin actually points.
usr/bin
df -h /Show disk usage in human-readable form for the root filesystem.
Filesystem Size Used Avail Use% Mounted on /dev/sda2 98G 34G 59G 37% /
cat /proc/meminfo | head -3Read the first three lines of virtual memory stats from /proc.
MemTotal: 16383924 kB MemFree: 9876504 kB MemAvailable: 14562000 kB
Examples
Map the tree before you touch anything
# See the top-level directoriesls / # Where do commands actually live?readlink /binreadlink /sbin # What is mounted, and how full is the disk?mount | head -3df -h / # Peek inside a running systemcat /proc/loadavgls /dev | head -5This 30-second survey tells you the FHS layout, which binaries are symlinks into merged /usr, what is mounted, and how full the disk is — the same five commands you run at the start of most incident investigations.
In production
- Check free bytes and inodes with df -h and df -i before claiming 'the disk is fine'.
- Watch /var/log for rotation with logrotate so application logs never fill the disk silently.
- Tune kernel behaviour by writing /proc/sys entries via sysctl instead of touching files directly.
- Mount network storage under /mnt or /srv rather than inside /home to keep user quotas and backups predictable.
- Containers expose their own minimal FHS tree, so debugging inside a container uses the exact same layout as a server.
Best practices
- Back up /etc before changing configuration; most servers can be restored from a clean /etc snapshot.
- Keep custom binaries in /usr/local/bin, never /usr/bin, so package upgrades cannot overwrite them.
- Run df -h and df -i together — a filesystem can be full of bytes or full of inodes.
- Store application data in /var/lib or /srv, never in /tmp, which is volatile and often cleared.
- Learn find and du early; they make exploring a 100 TB tree manageable.
Common mistakes
- Deleting files in /tmp to 'clean up' — running processes may hold them open and break in subtle ways.
- Writing directly to /proc/sys for a quick fix — changes are lost on reboot unless persisted in /etc/sysctl.conf.
- Assuming everything under / is one disk; a full /var mount can stop writes while / still has space.
- Typing rm -rf /var when you meant /var/log — always double-check before a recursive delete.
Common issues
df -h shows free space but writes fail with 'No space left on device'All inodes are used up — the filesystem cannot create new entries even though bytes remain.
Confirm with df -i, then find and remove unnecessary small files, e.g. find / -xdev -size 0 -delete.
mount: /data: wrong fs type, bad option, bad superblockA non-Linux filesystem (NTFS, exFAT) is being mounted or a driver is missing.
Check the type with blkid /dev/sdb1 and install the matching driver (e.g. ntfs-3g) before mounting.
Read-only file systemA hard remount or an fsck failure left the filesystem mounted read-only.
Remount writable with mount -o remount,rw /, and if it recurs run fsck from a rescue shell.
Debugging tips
- df -h shows a full disk instantly; df -i shows exhausted inodes.
- lsof +L1 finds files that were deleted but are still held open by a process.
- cat /proc/loadavg and cat /proc/meminfo give a live system snapshot with no installs.
- mount and /proc/mounts reveal exactly which device backs each path.
- find / -xdev -size +1G locates large files while staying on one filesystem.
Interview checkpoint
Hands-on lab
- List the top-level directories and state the role of each
- Identify symlinks such as /bin -> /usr/bin
- Inspect mount points and disk usage with mount and df
- Read kernel and hardware state from /proc and /sys
Map the Linux Filesystem Hierarchy
15 min · beginner
Quick quiz
Which directory holds system-wide configuration files?
Which of these is a pseudo-filesystem that shows running processes and kernel state?
On a modern FHS-compliant distribution, what is /bin?
Files written to /tmp are guaranteed to survive a reboot.
Which directory is the home directory for the root user?
You need to temporarily mount an external backup disk to inspect its contents. Which mount point is the conventional choice?
Cheat sheet
/etcSystem-wide configuration/varLogs, caches, spooled data/usrApplications, libraries, docs/homeUser home directories/rootHome of the root user/optOptional third-party software/srvService data (web, ftp)/bootBoot loader and kernel images/tmpTemporary files, cleared on reboot/runRuntime data for running processes/procKernel and process info as files/sysKernel/hardware attributes (sysfs)/devDevice files (/dev/null, /dev/sda)/mntTemporary manual mounts/mediaRemovable media auto-mounts/bin -> /usr/binEssential commands (symlink)/lib -> /usr/libShared libraries (symlink)/sbin -> /usr/sbinAdmin binaries (symlink)df -hDisk usage per filesystemdf -iInode usage per filesystemmountShow current mountsreadlink /binShow a symlink's targetdu -sh /varSize of a directorylsblkBlock devices and mount points