Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Filesystem Hierarchy: Where Everything Lives

Linux has no C:\ drive — everything hangs off a single root directory /, and each top-level folder has a strict job defined by the Filesystem Hierarchy Standard — learn the map and you can find any config, log, or program on any distro.


Why Learn This?

When someone says “check the logs” or “the config is in /etc”, the answer only makes sense if you know what those directories are. Beginners copy-paste paths from tutorials without understanding them; this page gives you the mental map so the paths stop being magic.

You will never need to memorize every directory. Learn the eight that matter daily — /, /bin, /etc, /home, /tmp, /var, /usr, /dev — and the rest you can look up the moment you need them.


1. Everything Starts at /

There is exactly one tree. Every directory, file, disk, and device lives under the root /:

/
├── bin      essential commands
├── etc      configuration files
├── home     people's files
├── tmp      temporary files
├── var      logs, spools, changing data
├── usr      programs and their data
├── dev      devices as files
└── ...

Unlike Windows, there are no drive letters. A second disk or USB stick is mounted into the tree at some directory (often /mnt or /media), becoming part of the one filesystem.


2. The Directories You Will Use Daily

DirectoryWhat lives there
/The root of everything
/binEssential commands: ls, cp, bash (now often a symlink to /usr/bin)
/etcSystem-wide configuration files, all plain text
/homeOne folder per user: ~, downloads, documents
/tmpTemporary files; wiped on reboot
/varThings that grow: logs, mail, web content, package caches
/usrUser programs: /usr/bin, /usr/lib, /usr/share
/devHardware and virtual devices as files (/dev/sda, /dev/null)

Example: the pieces of a typical command invocation:

sudo systemctl restart nginx
#  ^^^   ^^^^^^^^^  ^       ^^^^^
#  |     |          |       └── a unit file in /etc/systemd or /usr/lib/systemd
#  |     |          └----------- the binary /usr/bin/systemctl (or /bin)
#  |     └---------------------- run as root, config in /etc
#  └---------------------------- sudo config in /etc/sudoers

3. /etc: Where Configuration Lives

/etc is the closest thing Linux has to a registry — except every entry is a human-readable text file:

ls /etc
# adduser.conf  apt/  environment  group  hosts  network/  passwd  ssh/  ...

Key files you will meet early:

  • /etc/passwd — the list of users
  • /etc/hosts — local hostname → IP mappings
  • /etc/fstab — what gets mounted at boot
  • /etc/os-release — which distro this actually is

Example: check which distro you are on without any command:

cat /etc/os-release

4. /var: Where Things Grow

/var holds files that change size during normal operation:

  • /var/log — system and application logs (see the monitoring phase later)
  • /var/www — web server content (the classic Apache/Nginx default)
  • /var/cache — package and application caches
  • /var/mail — mailbox files for local users
  • /var/lib — state that must survive restarts (databases live here)

Example: the web server document root most tutorials assume:

ls /var/www/html

5. /usr: Programs and Their Data

Despite the name (historically “user programs”), /usr is not per-user — it holds installed software system-wide:

  • /usr/bin — most user-facing commands
  • /usr/sbin — administrative commands
  • /usr/lib — libraries programs load
  • /usr/share — architecture-independent data: docs, man pages, icons
  • /usr/local — software you installed by hand, kept separate from the package manager

Example: where a manually installed program’s man page lands:

man man          # /usr/share/man/man1/man.1.gz

6. /dev: Devices as Files

Every piece of hardware — and many abstractions — appears as a file in /dev:

ls /dev/null /dev/sda /dev/tty
# /dev/null  /dev/sda  /dev/tty
  • /dev/null — the black hole; anything written to it vanishes
  • /dev/sda, /dev/nvme0n1 — disks and partitions
  • /dev/tty — your current terminal
  • /dev/random — entropy source

Example: discard output completely:

./noisy-command > /dev/null 2>&1

7. The Directories You Should Recognize but Rarely Touch

DirectoryWhat it is
/bootKernel and bootloader files
/procA live window into the kernel and running processes
/sysKernel device and driver information
/optOptional: large third-party packages that install themselves
/mntWhere you manually mount disks while exploring
/mediaWhere desktops auto-mount USB drives
/runRuntime data since last boot (PID files, sockets)
/srvData served by this machine (shared files, web content)
/rootThe root user’s home directory — not /

/proc is the strangest and most fascinating: it is not on disk at all. cat /proc/cpuinfo reads live kernel data:

cat /proc/cpuinfo | head

8. Absolute vs Relative Paths

A path starting with / is absolute — it is complete from the root, always. Everything else is relative to your current directory:

cd /etc/ssl            # absolute: unambiguous from anywhere
cd ../etc/ssl          # relative: from wherever you are now
cd ./etc/ssl           # same as above — ./ means "here"

The shell tracks your position with pwd (covered in CLI Navigation):

pwd
# /home/user/projects

cd ../../etc
# from /home/user/projects → /home/user → /home → ... wait, that is two levels up: /home

Example: ~ is a shorthand for your home directory that the shell expands:

cd ~/downloads
# expands to /home/user/downloads before cd ever runs

Common Pitfalls

  • Looking for a C: drive — there is none; disks are mounted into the single tree, often under /mnt or /media.
  • /root is not / — the root user’s home is /root; the root directory is just /.
  • Editing files in /bin or /usr/bin — those are managed by the package manager; your edits get overwritten on the next update. Config goes in /etc, your own software in /usr/local.
  • Filling / or /var — logs and caches live there; a full root partition breaks the whole system. df -h (see File Operations) tells you the truth.
  • Assuming /tmp survives reboots — it usually does not; anything important belongs in /var/tmp or your home.
  • Trusting /usr = “user” — it has nothing to do with user accounts; it is where the distro keeps installed programs.
  • Writing to /proc or /sys casually — they are kernel interfaces; “files” there are live data, and some accept writes with real consequences.

PageWhy it is related
What Is Linux?The distro decides how these directories get filled
Terminal vs Shell vs Kernel/proc and /sys are the kernel showing itself
pwd, ls, and friendsThe commands for walking this tree
du and dfMeasuring what fills each directory

Filesystem Hierarchy Cheatsheet

PathWhat it is
/The one root everything hangs from
/bin, /usr/binCommands (ls, cp, most tools)
/etcSystem configuration, plain text
/home/userYour files (~)
/rootThe root user’s home
/tmpTemporary, wiped on reboot
/var/logLogs
/var/wwwWeb content
/usr/localSoftware you installed manually
/dev/nullThe black hole
/procLive kernel/process data
/mnt, /mediaMounted disks and USB sticks
/bootKernel and bootloader