Linux file system hierarchy.
Linux has a place for everything. Programs live in /usr, configuration lives in /etc, logs live in /var/log, user data lives in /home. Eight animated steps β one for each big directory β and you'll know where to look for any file.
Linux File System Hierarchy Standard (FHS) animated tour. Top-level directories: /home, /etc, /var, /usr, /tmp, /opt, /proc, /dev. Covers RHCSA EX200 exam objectives for filesystem layout.Linux organizes every file on the system under a single root directory called /. Below it sit a small number of well-known top-level directories β each with a specific job. Learn the eight big ones and you'll know where to look for anything.
- Β·Comfortable using cd, ls, and cat at the shell (if not, do the Command Line lesson first)
- Β·Roughly what 'a file' and 'a directory' are
Name the eight key top-level directories on a Linux system, say what each is for, and know which directory to look in for any common file.
pace: 8 minutes
/ β the root of everything
Linux has exactly one root directory. Every path on the system, regardless of which disk or partition it physically lives on, starts here. When you mount a USB drive at /mnt/usb, that mount point is just a subdirectory of /. There is no separate C: or D: drive β it's all one tree.
/homeΒ·user data/etcΒ·system configuration/varΒ·logs, mail, web roots β data that grows/usrΒ·installed programs and libraries/tmpΒ·temporary files/procΒ·kernel and process info (not on disk)/devΒ·device files (disks, terminals, /dev/null)/optΒ·optional third-party software$ls /$tree -L 1 /$df -hThe standard is called the FHS (Filesystem Hierarchy Standard). It's why your script that reads /etc/passwd works the same on RHEL, Debian, Arch, and Alpine. Knowing the FHS basics turns "where do I look?" into "I know where to look" β and that's most of what makes a sysadmin productive.
/the root β everything lives below/binessential commands (often symlink to /usr/bin)/sbinessential admin commands (often β /usr/sbin)/bootkernel images, initramfs, GRUB config/devdevice files (disks, terminals, /dev/null)/etcsystem-wide configuration/homeregular user home directories/libessential shared libs (often β /usr/lib)/mediaauto-mount points for removable media/mntmanual mount points (admin's playground)/optoptional third-party software/procvirtual: kernel + per-process info/rootthe root user's home directory/runruntime data β PIDs, sockets, locks (tmpfs)/srvdata for services (rarely used in practice)/sysvirtual: kernel devices, drivers, sysfs/tmptemp files, often tmpfs, cleared periodically/usrprograms + libraries from the package manager/varvariable data β logs, mail, caches, web rootsYou need to read SSH server settings. Which directory holds the config?
A disk filled up overnight. What directory should you investigate first?
What's special about /proc?
You ran `cat report.txt > /dev/null`. What happened?
These aren't graded β they're just for active recall, which is what actually makes the lesson stick.
Read this lesson as text8 chapters Β· quiz answers
01/ β / β the root of everything
Linux has exactly one root directory. Every path on the system, regardless of which disk or partition it physically lives on, starts here. When you mount a USB drive at /mnt/usb, that mount point is just a subdirectory of /. There is no separate C: or D: drive β it's all one tree.
- /home
- β user data
- /etc
- β system configuration
- /var
- β logs, mail, web roots β data that grows
- /usr
- β installed programs and libraries
- /tmp
- β temporary files
- /proc
- β kernel and process info (not on disk)
- /dev
- β device files (disks, terminals, /dev/null)
- /opt
- β optional third-party software
$ ls /β see what's at the root$ tree -L 1 /β one level deep, visualized$ df -hβ what's mounted where
02/home β /home β user data
Every user gets a directory here named after their login. This is where your documents, downloads, code, and dotfiles (config files starting with a
.) live. Only the owning user can read it by default. The root user's home is special: it lives at /root, not /home/root.- /home/alice
- β alice's entire personal world
- /home/alice/Documents
- β user documents
- ~/.bashrc
- β bash startup config (per-user)
- ~/.ssh/
- β SSH keys + known_hosts
- ~/.config/
- β modern app configs (XDG standard)
- /root
- β the root user's home (not /home/root!)
$ cd ~β your home, shorthand$ echo $HOMEβ where am I going with cd ~$ ls -la ~β see hidden dotfiles$ du -sh /home/*β how much each user is using
03/etc β /etc β system-wide configuration
If a service or the OS needs to be configured, its settings probably live in /etc. Almost everything here is a plain text file β easy to read, easy to edit with vim or nano, easy to put in git. The convention: machine-wide config goes here; per-user config goes in ~/.config or ~/.app-name.
- /etc/passwd
- β list of users (no actual passwords)
- /etc/shadow
- β password hashes (root-only)
- /etc/hostname
- β this machine's name
- /etc/fstab
- β what mounts where at boot
- /etc/ssh/
- β SSH server + client config
- /etc/systemd/
- β systemd unit files (admin)
- /etc/os-release
- β which distro and version
- /etc/cron.d/
- β system-scheduled jobs
$ cat /etc/os-releaseβ what distro is this?$ ls /etc | wc -lβ lots of stuff β count it$ grep -r ListenAddress /etc/sshβ search a service config
04/var β /var β variable data
Anything that grows during normal operation lives here: logs that accumulate, databases that get bigger, caches that fill up, mail queues, the web server's content. The opposite of /etc and /usr β those are mostly static. /var is where you look when something fills up the disk.
- /var/log/
- β system + service logs
- /var/log/messages
- β general kernel + service log (RHEL)
- /var/log/secure
- β auth + sudo events (RHEL)
- /var/lib/
- β stateful data for services (e.g. databases)
- /var/www/
- β default web root (Apache, nginx)
- /var/spool/
- β queues β mail, print, cron
- /var/cache/
- β caches (yum/dnf metadata, fontconfig)
- /var/tmp/
- β tmp that survives reboot (vs /tmp)
$ tail -f /var/log/messagesβ watch the log live$ du -sh /var/log/*β which logs are huge?$ journalctlβ systemd's modern log query
05/usr β /usr β programs and libraries
Almost everything installed by your package manager (rpm, dnf, apt) lands in /usr. The 'usr' originally stood for 'user', but modern Linux uses it for programs that come WITH the system. /usr/bin holds the commands you type every day. /usr/lib holds the shared libraries those commands need. /usr/local is reserved for stuff you install manually (not from the package manager).
- /usr/bin/
- β most commands (ls, cat, python, git, ...)
- /usr/sbin/
- β system admin commands (mkfs, fdisk, ...)
- /usr/lib/
- β shared libraries (.so files)
- /usr/lib/systemd/
- β package-shipped systemd units
- /usr/share/
- β arch-independent data (man pages, icons)
- /usr/share/doc/
- β docs that ship with packages
- /usr/local/
- β stuff YOU installed (not via package mgr)
$ which pythonβ where does this command live?$ ls /usr/bin | wc -lβ count of installed commands$ rpm -ql nginx | headβ files installed by a package
06/tmp β /tmp β temporary files
Anyone can write here. On modern RHEL, /tmp is usually a tmpfs (in RAM, not on disk) β fast but vanishes on reboot. Even if it's on disk, systemd-tmpfiles cleans up files older than 10 days. The sticky bit (the t in drwxrwxrwt) means even though everyone can write here, you can only delete your OWN files.
- /tmp/
- β world-writable scratch space
- /tmp/.X11-unix/
- β X server sockets (GUI)
- /var/tmp/
- β longer-lived tmp (survives reboot)
$ ls -ld /tmpβ see the sticky bit (the t)$ df -h /tmpβ is it tmpfs or on disk?$ mktempβ create a unique tmp file
07/proc β /proc β virtual filesystem (kernel & processes)
/proc isn't on any disk. The kernel generates its contents on the fly when you read from it. Every running process gets its own subdirectory named after its PID (/proc/1234/) where you can see what command it's running, what files it has open, what its environment is. Kernel-wide info lives at the top: /proc/cpuinfo, /proc/meminfo, /proc/cmdline.
- /proc/cpuinfo
- β every detail about the CPU(s)
- /proc/meminfo
- β memory + swap stats
- /proc/cmdline
- β kernel boot parameters
- /proc/uptime
- β seconds since boot + idle time
- /proc/<pid>/
- β one dir per running process
- /proc/<pid>/status
- β human-readable state
- /proc/<pid>/fd/
- β open file descriptors
- /proc/sys/
- β tunable kernel parameters (sysctl)
$ cat /proc/cpuinfo | grep 'model name' | head -1β what CPU?$ cat /proc/$$/statusβ info on the current shell$ free -hβ memory summary (reads /proc/meminfo)
08/dev β /dev β devices as files
Linux treats every device as a file. Reading from /dev/sda reads from the first disk. Writing to /dev/tty1 prints on console 1. Writing to /dev/null silently discards data. Reading from /dev/urandom gives you random bytes forever. The udev daemon populates and updates /dev as hardware connects and disconnects.
- /dev/null
- β the bit bucket β writes discarded
- /dev/zero
- β reads return endless zero bytes
- /dev/urandom
- β reads return random bytes (crypto-safe)
- /dev/sda, /dev/nvme0n1
- β block devices (whole disks)
- /dev/sda1
- β partition 1 of /dev/sda
- /dev/mapper/vg-lv
- β LVM logical volumes
- /dev/tty1
- β first virtual console
- /dev/pts/
- β pseudo-terminals (ssh, terminal emulators)
$ ls /dev | headβ see what's there$ dd if=/dev/zero of=/tmp/blob bs=1M count=10β make a 10MB file of zeros$ head -c 16 /dev/urandom | xxdβ 16 random bytes, hex$ command > /dev/null 2>&1β silence all output
Quiz β answers
- You need to read SSH server settings. Which directory holds the config?
- β/etc/sshSystem-wide configuration lives in /etc. SSH server config is /etc/ssh/sshd_config.
- A disk filled up overnight. What directory should you investigate first?
- β/var (especially /var/log) β that's where data grows/var holds anything that grows during operation. Logs in /var/log are the most common culprit. Use
du -sh /var/* | sort -hto find the heavy hitters. - What's special about /proc?
- βIt's a virtual filesystem β the kernel generates its contents on the fly; nothing is on disk/proc and /sys are kernel windows. They let userspace read (and sometimes write) kernel state via the file API.
- You ran
cat report.txt > /dev/null. What happened? - βThe contents were discarded β /dev/null silently eats anything written to it/dev/null is the universal discard. Common pattern:
command 2>/dev/nullsilences error output you don't care about.
keep going β these pair well with what you just learned.
SELinux contexts
Why Apache can't read your file. Watch the policy engine decide β and learn the workflow for fixing denials. RHCSA-ready.
Linux boot process
From power button to login prompt. Every stage in the chain β UEFI, GRUB, kernel, initramfs, systemd β with the rescue moves that save you. RHCSA-ready.
LVM stacking
Layer-by-layer build of an LVM stack: disks β PVs β VG β LVs β filesystem. Then extend live and snapshot. RHCSA-ready.