$_ CLI In Depth
Learning progress 0%
lesson filesystem inodes navigation

The Filesystem Hierarchy: /, /etc, /usr, /var & /proc

5 min read Module 2: Filesystem Navigation & Inodes Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:13

One tree with one root

On Linux every file lives somewhere under a single directory called the root, written as a slash. There are no drive letters. A disk, a USB stick, a network share, or a virtual filesystem is attached at some directory, called a mount point, and from then on its contents appear as ordinary directories underneath that point. When you type cd /var/log, the shell does not care which device stores those files. The kernel resolves the name one component at a time, starting at the root, and it follows whatever filesystem is mounted at each step.

This model explains several things that surprise newcomers. A directory can be a mount point, so its old contents are hidden while a filesystem is attached over it. Two machines can share the same path name for different data. And a path such as /proc/version does not exist on any disk at all, because the kernel generates its contents at the moment you read it.

The top-level directories

The Filesystem Hierarchy Standard is a convention, not a law, but nearly every distribution follows its general plan. The table lists the directories that appear throughout this course and the question each one answers.

DirectoryWhat lives there
/bin, /sbinEssential programs needed to boot and repair the system
/usrMost installed software: /usr/bin, /usr/lib, /usr/share
/etcSystem-wide text configuration
/home, /rootPer-user home directories, and the home directory of the root account
/varData that changes while the system runs: logs, caches, mail, spool queues
/tmpTemporary files, usually cleared at boot or on a timer
/devDevice files for terminals, disks, and special devices such as /dev/null
/proc, /sysVirtual filesystems that expose kernel state and settings
/runRuntime data for the current boot, usually kept in memory

Where software and configuration belong

Programs you did not write usually sit under /usr. The executables are in /usr/bin, shared libraries in /usr/lib, and architecture-independent data such as documentation templates and locale files in /usr/share. Software that you build yourself and install without a package manager often goes to /usr/local, which keeps it apart from the packaged system. Configuration is different. Text files that control how a service or the whole machine behaves are placed in /etc, so an administrator can back up one directory and recover most of what makes the machine behave the way it does.

The split between programs and configuration is also a safety property. Ordinary users cannot write to /usr/bin or to most of /etc, so a mistake in an ordinary session cannot silently replace a system program. The permissions shown by ls -ld reveal who may create files in a directory, and a later unit explains how to read them.

BASH1 lines
ls -ld /etc /usr/bin /var /tmp

Read the first column of each line. The leading character is the file type, and the nine characters after it are the permission bits. The directory /tmp is usually writable by everyone, and the sticky bit on it is what stops one user from deleting another user's files there. That detail belongs to the permissions module, so for now notice only that the directories differ.

Changing data: /var and /tmp

Files that grow or change while the system runs belong in /var. Logs go to /var/log, package caches to /var/cache, and queues such as outgoing mail to /var/spool. Keeping this data apart from /usr lets an administrator mount /var on its own disk. It also means a log that fills up cannot stop the programs in /usr from running, because they are on a different filesystem.

/tmp holds scratch files that you can afford to lose. Many systems mount it as a memory-backed filesystem, which is why it is fast and empty after a reboot. A program that writes to a predictable name in /tmp needs care, because another user may create the same name first. The permissions module returns to this problem.

Windows into the kernel: /proc, /sys and /dev

The directories /proc and /sys look like files and directories, but the kernel generates their contents on demand. Reading /proc/version asks the kernel for its version string, and writing to some files under /proc/sys changes kernel parameters. Every running process has a directory under /proc named by its process ID, and the special name self refers to the process that is doing the reading. Inside your shell, $$ expands to the shell's own PID, so /proc/$$ is the directory of your shell.

/dev holds device files. A device file is an entry in the tree that connects a name to a kernel driver. Writing to /dev/null discards the data, and reading from it returns end of file at once. Terminals appear as names such as /dev/pts/0, which the first module described.

BASH3 lines
cat /proc/version
echo "my shell is PID $$"
ls -l /proc/$$/cwd

The last command shows a symbolic link. The entry cwd is a link whose target is your shell's current directory, which is one of several facts the kernel exposes through /proc. The output of the first command begins with the word Linux and then the kernel release, followed by build details that vary from one kernel to the next.

Practice the layout in the lab

Start with ls / and compare the names with the table. Then read the identity of the distribution with cat /etc/os-release. The lab runs an Alpine Linux userland on a real kernel, so the names are the same as on a desktop system while the contents of some directories are smaller than you might expect.

Tip

The lab has no man pages. For a quick reminder of what a directory is for, use ls and cat on its files. For the authoritative description of the layout, the man7.org page for hier(7) is the reference. Many minimal containers ship without man pages, so get used to asking the program itself with --help.

Resolving a path one component at a time

Visualizer

The kernel resolves a path left to right, one name at a time, starting at / for absolute paths or at the current directory for relative ones.

1 / 5
..
/
etc
/
.
/
passwd
Resolution
startcwd = /workspace
..parent → /
etclook up "etc" in / → /etc
.same directory → /etc
passwdlook up "passwd" in /etc → /etc/passwd

A relative path does not start with /, so resolution starts in the current working directory, /workspace.

cd /workspace; realpath ../etc/./passwd; ls -l ../etc/./passwd
Terminal lab · 3 steps · real Linux in your browser

Map the top of the filesystem

List the root directory, read the kernel version from /proc, and identify the distribution from /etc.

01
List the top level
Save the names in the root directory to a file, one name per line: ``bash ls -1 / > top-level.txt `` Compare the names with the table of directories in the lesson.
Show hint for step 1
ls -1 prints one name per line, and the redirection saves the output in /workspace.
02
Read the kernel version
The file under /proc is generated by the kernel when you read it. Save its contents: ``bash cat /proc/version > kernel.txt ``
Show hint for step 2
cat /proc/version prints one line that starts with the words Linux version.
03
Identify the distribution
The file /etc/os-release describes the userland. Save its ID line: ``bash grep '^ID=' /etc/os-release > distro.txt ``
Show hint for step 3
The line you want begins with ID= and is the only such line in the file.
Check yourself Question 1 of 4
Concept Check System-wide configuration recall

Which top-level directory is the conventional place for system-wide text configuration files?

Recap & Key Takeaways

Linux has one tree that starts at /, and other filesystems are attached to it at mount points.
/usr holds most installed software, /etc holds configuration, and /var holds data that changes while the system runs.
/proc and /sys are generated by the kernel on demand, so their files do not live on a disk.
/dev holds device files, and /dev/null discards everything written to it.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue