DevOps Peach

Linux · Linux Basics – Files, Directories, and Permissions · Lesson 2 of 6

Linux Filesystem Hierarchy

Read the Linux directory tree and choose the right path form.

Practice interactively →

One tree rooted at /

Every Linux path is below the root directory /. There are no drive letters as on Windows: a second disk or USB stick is mounted into a directory of the same tree. /root is only the superuser's home; regular users normally have /home/<user>.

The layout follows the Filesystem Hierarchy Standard (FHS), so the same directories exist on almost every distribution.

Location Typical role
/etc System-wide configuration
/var/log Logs that change over time
/var/lib Application state such as databases and package data
/usr Most programs and read-only data
/bin, /sbin Essential commands; modern distros often link them into /usr
/opt Optional software installed as a self-contained bundle
/tmp Temporary files, often cleared at reboot
/home Users' personal directories
/boot Kernel and bootloader files
/dev Device files such as disks and terminals
/proc Virtual filesystem exposing kernel and process state
/mnt, /media Mount points for extra or removable storage
flowchart TB
  R["/ root<br/>one tree"] --> ETC["/etc<br/>configuration"]
  R --> HOME["/home<br/>user files"]
  R --> VAR["/var<br/>logs, data"]
  R --> BIN["/usr/bin<br/>programs"]
  R --> DEV["/dev, /proc<br/>devices, processes"]
  HOME --> ME["/home/alice<br/>~ for alice"]
  %% step R: Every path starts at the single root directory, even other disks are mounted inside it.
  %% step ETC: System-wide configuration lives in /etc, such as /etc/ssh/sshd_config.
  %% step HOME: Each user gets a home directory under /home.
  %% step VAR: Data that grows, like /var/log, lives under /var.
  %% step BIN: Installed programs live in /usr/bin and /usr/sbin.
  %% step DEV: Devices and kernel information appear as files under /dev and /proc.
  %% step ME: ~ is shorthand for your own home; a relative path starts from the current directory.

Everything is a file

Linux presents many things as files: a disk is /dev/sda, process details live under /proc/<pid>, and the CPU is described in /proc/cpuinfo. That is why cat and less can inspect so much of the system.

Absolute and relative paths

A path beginning with / is absolute, while docs/report.txt is resolved relative to the current directory. . means the current directory and .. its parent, so cd ../logs moves to a sibling. cd - jumps back to the previous directory.

Names are case-sensitive: Report.txt and report.txt are different files. A name starting with a dot, such as .bashrc, is hidden from plain ls.

Commands to explore

pwd prints the current directory, cd ~ returns home, and ls / lists the top level. The shell expands ~; it is not literally a directory named tilde. df -h shows mounted filesystems and their free space.

Do not confuse / with /root, or look under /usr for changing logs merely because the program is installed there.

Practice interactively →