Skip to content
6 min read·Lesson 3 of 10

The Linux Filesystem Hierarchy

Learn how Linux organises every file and directory under a single root, and what lives where in the standard hierarchy.

On Windows, you have drive letters (C:\, D:\). On Linux, there is only one starting point: /, called the root directory. Everything — disks, USB drives, processes, network sockets — is represented as a file or directory somewhere under /.

Why a Single Hierarchy?

This design, inherited from Unix, makes the system consistent and scriptable. You never need to know which physical disk something is on — you just know its path. External drives are "mounted" into the tree, meaning they appear as directories like /mnt/data or /media/usb.

The Most Important Directories

/ — Root

The top of the entire filesystem. No directory is above /. Only the root user can write here directly.

/etc — Configuration Files

System-wide configuration lives here. Nearly every service you install puts its config in /etc:

  • /etc/nginx/nginx.conf — Nginx web server config
  • /etc/ssh/sshd_config — SSH server settings
  • /etc/fstab — Disk mount configuration
  • /etc/hosts — Local hostname-to-IP mappings

/home — User Home Directories

Each regular user gets a directory here: /home/alice, /home/bob. This is where personal files, shell configs (.bashrc, .bash_history), and application data live. The root user's home is /root, not under /home.

/var — Variable Data

Data that changes over time: logs, databases, caches, mail spools.

  • /var/log — System and application log files
  • /var/lib — Application state (e.g., database files)
  • /var/tmp — Temporary files that persist across reboots

/tmp — Temporary Files

Temporary scratch space, cleared on reboot. Programs use this for short-lived files. Anyone can write here.

/bin and /sbin — Essential Binaries

/bin contains commands needed to boot and repair the system: ls, cp, mv, bash. /sbin contains system administration binaries: fdisk, fsck, iptables. On modern systems (Ubuntu 20.04+, RHEL 8+) these are symlinked to /usr/bin and /usr/sbin.

/usr — User Programs

The bulk of installed software lives here:

  • /usr/bin — User commands installed by packages
  • /usr/lib — Shared libraries
  • /usr/share — Architecture-independent data (docs, icons)
  • /usr/local — Software compiled and installed manually (not by the package manager)

/proc and /sys — Virtual Filesystems

These directories contain no real files. They're interfaces to the running kernel:

  • /proc/cpuinfo — CPU details
  • /proc/meminfo — Memory usage
  • /proc/1/ — Information about the process with PID 1 (systemd)
  • /sys/class/net/ — Network interface settings

/dev — Device Files

Hardware devices appear as files: /dev/sda (first disk), /dev/null (discard everything written to it), /dev/zero (produces endless zero bytes), /dev/random (random data source).

/opt — Optional Software

Third-party applications that don't follow the standard layout install here. Example: /opt/google/chrome/.

Navigating the Hierarchy

Two types of paths:

  • Absolute path: starts with /, e.g. /etc/nginx/nginx.conf. Always unambiguous.
  • Relative path: relative to your current directory, e.g. ../config/settings.json.

Special symbols:

  • ~ — Your home directory (/home/yourname)
  • . — Current directory
  • .. — Parent directory

Quick reference commands:

pwd          # print working directory (where am I?)
ls /etc      # list contents of /etc
ls -la ~     # list home directory with hidden files
cd /var/log  # change to /var/log
cd ~         # return home
cd ..        # go up one level

In the next lesson, you'll go deeper into the terminal itself — how to use it effectively with shortcuts, history, and command composition.

Key Takeaways

  • Linux uses a single-rooted tree: everything lives under / (root).
  • /etc holds configuration files; /var holds variable data like logs; /home holds user files.
  • /bin and /sbin contain essential binaries; /usr/bin contains user-installed programs.
  • Knowing where config files live is essential for debugging servers and containers.
  • The Filesystem Hierarchy Standard (FHS) defines these conventions across distros.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →