Skip to content

The Linux Filesystem Hierarchy

A fresh Linux system you just installed presents one unified directory tree starting at /. This page maps that tree using the Filesystem Hierarchy Standard (FHS) so you always know where configs, logs, programs, and devices live — knowledge you'll lean on for the rest of your career.

Tested on

AlmaLinux 9.4. The FHS is a cross-distro standard, so this layout applies to virtually every Linux system, with only minor differences.

One tree, rooted at /

Unlike Windows, Linux has no C: or D: drives. There is a single hierarchy that begins at the root directory / (just a forward slash). Every file, directory, and device — and even additional disks — hangs off that one tree. When you attach another disk or a USB stick, you mount it onto a directory (e.g. /mnt/backup), and it appears as a branch of the same tree.

# List the top of the tree
ls -l /
dr-xr-xr-x.  19 root root  4096 Jun  7 09:12 boot
drwxr-xr-x.  20 root root  3380 Jun  7 09:12 dev
drwxr-xr-x. 145 root root  8192 Jun  7 09:12 etc
drwxr-xr-x.   3 root root    18 May 10 14:02 home
... and so on

"Everything is a file"

A defining Linux philosophy: almost everything is represented as a file. Not just documents and programs, but also:

  • Hardware devices — your first disk is the file /dev/sda; the console is /dev/tty1.
  • Kernel and process information — exposed as files under /proc and /sys.
  • Pipes and sockets — inter-process communication appears as special files.

The payoff is a uniform interface: the same tools (cat, ls, >) and the same permission model work on a text file, a hard disk, and a kernel setting alike. For example, you can read your CPU info with a plain cat:

cat /proc/cpuinfo      # the kernel presents CPU details as a readable file

The top-level directories at a glance

Path Purpose
/ The root of the entire filesystem. Everything lives under it. (Not the same as /root.)
/etc System-wide configuration files, all plain text. e.g. /etc/ssh/sshd_config, /etc/fstab, /etc/os-release.
/var Variable data that changes as the system runs — logs, caches, mail, databases, print spools.
/var/log Log files. Your first stop for troubleshooting: /var/log/messages, /var/log/secure, service logs.
/home Per-user home directories, e.g. /home/deepak. Personal files and per-user config.
/root The root user's home directory. Deliberately separate from /home so it's available even if /home isn't mounted.
/usr The bulk of installed user-space software — programs, libraries, docs. Read-only in normal operation.
/usr/local Software you install manually (compiled from source), kept separate from packaged software so updates don't clobber it.
/bin Essential user commands (ls, cp, cat). On modern distros it's a symlink to /usr/bin.
/sbin Essential system/admin commands (fdisk, ip, mount). Symlink to /usr/sbin on modern distros.
/lib, /lib64 Essential shared libraries and kernel modules needed to boot and run /bin+/sbin. Symlinks to /usr/lib* on modern distros.
/opt Optional, self-contained third-party software (often commercial), each in its own subdirectory.
/tmp Temporary files for any program. Often cleared on reboot; never store anything you want to keep here.
/boot The bootloader (GRUB), the Linux kernel (vmlinuz), and the initramfs. Frequently its own partition.
/dev Device files: /dev/sda (a disk), /dev/null (the bit bucket), /dev/random.
/proc A virtual filesystem of running processes and kernel state, generated in memory. e.g. /proc/cpuinfo, /proc/<pid>/.
/sys A virtual filesystem exposing devices, drivers, and kernel tunables (sysfs).
/mnt A generic, conventional mount point for temporarily mounting filesystems by hand.
/media Where removable media (USB sticks, CDs) auto-mount, e.g. /media/usb.
/srv Data served by this system to others — e.g. files for a web or FTP server (/srv/www).
/run Runtime data since boot: PID files, sockets. A tmpfs (RAM-backed), wiped on every boot.

The /usr merge

On AlmaLinux 9 and most modern distros, /bin, /sbin, /lib, and /lib64 are just symlinks into /usr. You'll see bin -> usr/bin in ls -l /. The split is historical (from when /usr lived on a separate disk); the FHS table above still describes their roles.

Configs, logs, and data: the three you'll touch most

As an admin, three locations dominate daily work:

  • /etc"I need to change a setting." Edit a text file here, restart the service.
  • /var/log"Something broke." Read the logs here (or via journalctl for systemd services).
  • /home and /srv"Where's the data?" User files and served content.
# A typical troubleshooting trio
sudo less /etc/ssh/sshd_config       # what's configured
sudo tail -f /var/log/secure         # what's happening (auth events), live
journalctl -u sshd --since today     # systemd's view of the sshd service

Absolute vs relative paths

  • An absolute path starts with / and is unambiguous from anywhere: /var/log/messages.
  • A relative path is interpreted from your current directory: from inside /var, the relative path log/messages refers to the same file.

Two special shortcuts help with relative paths:

  • . — the current directory.
  • .. — the parent directory.
  • ~ — your home directory (/home/deepak).
pwd                      # where am I? -> /var/log
cat messages             # relative: /var/log/messages
cat ../lib/os-release    # relative with .. -> /var/lib/os-release
cat /etc/os-release      # absolute: same no matter where you are
cd ~                     # jump to your home directory

Tip

Always use absolute paths in scripts, cron jobs, and config files. Relative paths depend on where the process happens to start, which is a classic source of "works in my terminal, fails in cron" bugs.

Exploring the tree

# Long listing of the root, showing permissions and symlinks
ls -l /

# A one-level-deep tree view (install with: sudo dnf install tree)
tree -L 1 /
/
├── boot
├── dev
├── etc
├── home
├── opt
├── proc
├── root
├── run
├── srv
├── sys
├── tmp
├── usr
└── var
# The built-in manual page describing this entire layout
man hier

Tip

man hier ("hierarchy") is the canonical, always-available reference for this page's contents. When you forget what /srv is for on a server with no internet, man hier has the answer.

Verify your work

# 1. List the top-level directories and spot the /usr symlinks
ls -l /

# 2. Read the FHS manual to confirm a directory's purpose
man hier

# 3. Prove "everything is a file": read kernel state as if it were a text file
cat /proc/uptime          # seconds the system has been up

# 4. Practice absolute vs relative paths
cd /var/log && pwd && ls && cat ../../etc/os-release | head -1

# 5. Find where a command actually lives
which ls                  # likely /usr/bin/ls

You should now be able to predict, for any task, which directory to look in: configs → /etc, logs → /var/log, your programs → /usr/local, devices → /dev.

Summary

  • Linux has one unified tree rooted at / — no drive letters; extra disks are mounted into the tree.
  • Everything is a file, including devices (/dev) and kernel state (/proc, /sys), giving one consistent toolset.
  • Know the heavy hitters: /etc (config), /var/log (logs), /home (user data), /usr (installed software), /boot (kernel), /dev (devices).
  • On modern distros, /bin, /sbin, and /lib* are symlinks into /usr.
  • Absolute paths start at / and are safe everywhere; relative paths depend on your current directory — prefer absolute paths in scripts.
  • Explore with ls -l /, tree -L 1 /, and the authoritative man hier.
  • Next: drive the system from the shell.

Test yourself