The Linux Directory Structure, Explained
Run ls / on any Linux machine and you'll see the same two dozen directories — a layout standardized as the Filesystem Hierarchy Standard (FHS). Once you know what each one is for, an unfamiliar server stops being a maze: configs are always in one place, logs in another, and "where would that be?" answers itself.
One tree, everything included
Unlike Windows with its drive letters, Linux has a single tree rooted at /. Disks, USB sticks and network shares don't get letters — they're mounted onto directories inside the tree. Even hardware and kernel state appear as files. "Everything is a file" is the founding design decision, and the directory layout is its map.
/.The directories you'll actually visit
| Directory | What lives there |
|---|---|
/home | One personal directory per user (/home/diego). Your files, your dotfiles, your mess. ~ expands to yours. |
/etc | System-wide configuration, as editable text files: /etc/nginx/, /etc/ssh/sshd_config, /etc/hosts, /etc/crontab. When you need to configure anything, start here. |
/var | Variable data — things that grow: logs (/var/log), databases (/var/lib), mail queues, website roots (/var/www). When a disk fills up, the culprit is usually somewhere in /var. |
/usr | Installed programs and their support files. /usr/bin holds most commands you run; /usr/share their data; /usr/local is for software you install manually, outside the package manager. |
/tmp | Scratch space for anyone and anything. Assume it's wiped on reboot — never store something you want to keep. |
/opt | Optional, self-contained third-party applications — commercial software and things that ship as "one big directory" often land in /opt/appname. |
/root | The administrator's home directory. Not /home/root — it lives apart so root can log in even if /home fails to mount. |
/bin, /sbin, /lib | Essential commands and libraries. On modern distros these are symlinks into /usr — historical layers made compatible. |
The special ones: windows into the kernel
| Directory | What it really is |
|---|---|
/proc | Not a real disk directory — a live view of the kernel. /proc/cpuinfo describes your CPU, /proc/meminfo your memory, and each running process has a numbered directory (/proc/1234/) that tools like ps read. |
/sys | The device and driver view: kernel objects exposed as a file tree. Mostly for tools, occasionally for tuning. |
/dev | Devices as files: /dev/sda is your first disk, /dev/null the famous black hole, /dev/urandom a randomness tap. Writing to a device file writes to the device. |
/mnt, /media | Conventional mount points: /media for auto-mounted USB drives, /mnt for manual/temporary mounts. |
/boot | The kernel itself and the bootloader. Small, critical, and the one place where "cleaning up old files" requires real care. |
Where to look when something breaks
- A service misbehaves → its config in
/etc/servicename/, its logs in/var/log/servicename/(orjournalctl -u servicenameon systemd). This pair answers most questions. - Disk full → df -h to confirm, then hunt in
/varfirst:du -h --max-depth=1 /var | sort -hr. - "command not found" for something installed →
echo $PATHand check whether it landed in/usr/local/bin,/opt/app/binor~/.local/bin— directories that may not be on the search path. - What's eating the CPU → the answer lives in
/proc, read comfortably throughtopor ps aux --sort=-%cpu. - Which disk is which →
lsblkshows devices from/devand where each is mounted in the tree.
Three rules of thumb
Configs are text in /etc — editable, diffable, versionable; back them up before editing (cp file file.bak, see cp). Anything that grows lives in /var — plan disk space there. Your experiments belong in /home, /tmp or /opt — the package manager owns /usr, and fighting it ends badly.
Keep going
Practice navigating with the interactive course, and see the cd, ls and find references for moving through the tree efficiently.