Chapter 1. Introduction — How to Read a Linux Path
Run ls -l / in Ubuntu. Some names look familiar, such as home and tmp. Others, including etc and proc, give few clues. The first useful question is what a path tells you about the item at its end. Consider three paths for one program: /usr/bin/ssh is an executable, /etc/ssh/ssh_config holds system-wide client settings, and ~/.ssh/config holds one user’s choices. Their positions tell you who manages them and how they are used.
The initial slash in an absolute path means “start at the root of the directory tree.” A second filesystem can join that tree at a directory called a mount point. As a result, two neighboring names under / can lead to entirely different places: files on your Linux disk, information supplied by the kernel, or even your Windows drive. This tour covers fifteen widely encountered directories. A particular installation may have others.
Chapter 2. /home — Each User’s Working Directory
On an Ubuntu account named steve, /home/steve normally contains the user’s projects, downloads, and personal settings. Bash expands ~ to the current user’s home directory. Typing cd ~/linux-practice therefore takes Steve to /home/steve/linux-practice, wherever he started.
Run ls -a ~ to include names beginning with a dot. A file such as .bashrc can customize the interactive Bash shell for this account. That scope matters on a shared machine. Two people can use the same installed Bash executable and get different prompts because each has a separate home directory.
Chapter 3. /root — The Administrator’s Home
Linux has a privileged account called root. Its home directory is conventionally /root. Compare the paths carefully: / is the starting point for every absolute path, while /root is one directory immediately below it. A command run with sudo can execute as root while keeping the current working directory.
Why give the administrator a separate location? A machine may mount its users’ homes from a second disk or a network server. Keeping the administrator’s home on the root filesystem allows local administrative files to remain available when that separate mount fails. Run ls -ld /root to inspect the directory’s ownership and permissions without entering it.
Chapter 4. /etc — System-Wide Configuration
A program needs both instructions and policy. The SSH client executable implements the protocol. Its system configuration can specify how the client should behave on this machine. Files under /etc commonly express those local choices. Other examples include /etc/hostname for the host name and /etc/fstab for configured filesystem mounts.
Compare /etc/fstab with findmnt. The first describes mounts configured through that file. The second shows what is mounted now. An automatically mounted drive can appear in the live list even when there is no matching line in fstab. That difference between configuration and current state recurs throughout the hierarchy.
Chapter 5. /bin — Commands Available to All Users
Historically, /bin held essential commands such as sh, ls, and cp. When a separate filesystem containing additional software was unavailable during startup or repair, tools on the root filesystem still had to work. This history helps explain why so many shell scripts begin with #!/bin/sh.
On a modern Ubuntu installation, try ls -ld /bin and readlink -f /bin/sh. The first can show that /bin points to usr/bin. The second follows every link to the actual shell executable. The familiar pathname still works, and the system can maintain one copy of the executable.
Chapter 6. /sbin — System Administration Commands
The traditional /sbin directory groups system tools associated with tasks such as preparing filesystems and repairing a machine. For example, fsck is a front end for filesystem consistency checkers. On a system with a merged /usr layout, /sbin commonly points into /usr. Inspect the link with ls -ld /sbin.
The directory name describes a tool’s purpose. Actual privileges depend on the operation, the resource, and the process credentials. An ordinary user can often read a tool’s help or inspect public information even when changing the underlying system requires administrator privileges.
Chapter 7. /lib — Libraries, Loaders, and Kernel Modules
Several executables can call functions supplied by the same shared library. A dynamically linked program also relies on a loader to locate the required libraries when it starts. On Ubuntu, ldd /usr/bin/ls shows the shared objects used by the installed ls executable. Architecture-specific components may appear in a subdirectory such as x86_64-linux-gnu.
The conventional path /lib/modules/ serves a different purpose. Its versioned subdirectories can contain modules built for specific kernels, including device drivers. A shared library supplies code to a user-space process, while a kernel module supplies code to the running kernel. On merged systems, /lib itself can be a symbolic link.
Chapter 8. /usr — The Installed Software Tree
Follow the installed files for a familiar command. Its executable may live under /usr/bin, its libraries under /usr/lib, and its manual page under /usr/share/man. A package manager can install these pieces together even though the hierarchy groups them by purpose. On Ubuntu, try dpkg -L coreutils | less to inspect the paths recorded for one package. Press q to exit.
Two other locations help explain installation choices. Administrators can install locally maintained software under /usr/local, keeping it distinct from distribution packages. A vendor supplying an application as a self-contained directory may use the separate top-level location /opt. Personal documents belong under the user’s home.
Chapter 9. /boot — Files Used to Start Linux
On a conventional Ubuntu PC, /boot often contains a kernel image with a name beginning vmlinuz and an initial RAM filesystem image beginning initrd.img. The bootloader loads the kernel and the initial image. That image supplies an early environment that can provide the tools and drivers needed to reach the main root filesystem.
Run uname -r to see the running kernel release, then inspect ls /boot. A PC may retain files for several kernel releases even though only one kernel is running. Under WSL 2, Windows manages the Linux kernel used by the virtual machine, so the Ubuntu distribution’s /boot can be empty.
Chapter 10. /dev — Device Interfaces with Pathnames
Programs can interact with many devices through special files called device nodes. Their names appear under /dev. Reading or writing such a path invokes behavior implemented by the kernel. For example, /dev/null accepts writes and discards the bytes. Running printf 'hello\n' > /dev/null therefore produces no visible output.
Try tty in an interactive Ubuntu terminal. A result such as /dev/pts/0 identifies the terminal device attached to the session. Then run ls -l /dev/null. A leading c in the listing identifies a character device. The pathname convention lets familiar shell operations, including redirection, work with a device interface.
Chapter 11. /proc — A Live View of Processes and Kernel State
Run echo $$ in Bash. The number is the shell’s process ID. Now enter head /proc/$$/status. Bash inserts the same number into the path, and the kernel supplies details about that particular shell. When a process exits, its entry disappears. A later process may reuse the number.
Other entries summarize the system. For example, head /proc/meminfo shows memory figures exposed by the running kernel. These file-like entries belong to a virtual filesystem called procfs. Reading one asks the kernel for information. Under WSL 2, the figures describe the Linux environment’s view of memory, which can differ from the totals displayed by Windows.
Chapter 12. /sys — How the Kernel Organizes Devices
The sysfs filesystem exposes kernel objects and their relationships. To see why that matters, run ls /sys/class/net. Each name represents a network interface visible to Linux. The loopback interface, lo, carries traffic within the local system. Read cat /sys/class/net/lo/mtu to see its configured maximum transmission unit in bytes.
A class groups devices by the function they provide. Try readlink -f /sys/class/net/lo to follow the class entry to its place in the kernel’s device tree. Together, /dev and /sys answer different practical questions. A device node can provide an I/O endpoint. A sysfs entry lets you inspect an object’s identity, relationships, or attributes.
Chapter 13. /run — State for the Current Boot
A service may need a location for a communication socket, a lock, or a file recording its current process ID. Such information often belongs under /run. On typical modern Linux systems this directory uses a memory-backed filesystem, and its contents are recreated during boot as services start.
A PID file from yesterday could identify an entirely different process today. Giving current runtime state its own lifetime helps prevent that confusion. Run ls -ld /run /var/run. On Ubuntu, the older pathname /var/run generally points to /run, so older programs can reach the current runtime directory.
Chapter 14. /var — Logs, Databases, and Other Changing Data
Look under /var when the system is accumulating information during normal operation. Three branches illustrate why the distinction matters: /var/log holds logs, /var/cache holds data applications can regenerate, and /var/lib holds application or system state that may be essential to recover.
On Ubuntu, the package database includes /var/lib/dpkg/status. Downloaded package archives can appear under /var/cache/apt/archives. Both concern installed software, yet losing a cached download has a very different consequence from losing the record of what is installed. A backup or disk-cleanup decision therefore needs the full path, not just the observation that everything under /var changes.
Chapter 15. /tmp — Temporary Workspace
Programs use /tmp for short-lived work. Its contents may be removed during boot or by an age-based cleanup policy. A program that expects a user to reopen a saved result next week needs a more durable location. The separate /var/tmp convention is intended for temporary files that should survive a reboot.
Run ls -ld /tmp. On a typical shared system the permissions end in t, the sticky bit. Users can create entries there, while removal or renaming is generally restricted to the entry owner, the directory owner, or a privileged process. For a shell experiment, mktemp -d creates a fresh private directory and prints the exact path.
Chapter 16. /mnt — Where Another Filesystem Joins the Tree
A mount point is a directory at which Linux attaches the root of another filesystem. The traditional role of /mnt is to provide a convenient location for temporary mounts made by an administrator. Desktop environments commonly use locations under /media or /run/media for automatically mounted removable drives.
In a default WSL setup, /mnt/c exposes the Windows C: drive. Compare findmnt -T ~ and findmnt -T /mnt/c. Look at the TARGET and FSTYPE columns. The two paths can lead to different filesystems while both start with the same slash. On a native Linux PC, use findmnt -T / and examine another mount listed by findmnt.
Chapter 17. Conclusion — Follow One Service Through the Hierarchy
Suppose an Ubuntu machine runs an SSH server. The server executable is commonly /usr/sbin/sshd. Its machine-wide configuration lives in /etc/ssh/sshd_config. A user named Steve may store authorized public keys in /home/steve/.ssh/authorized_keys. Once the server is running, its process has an entry under /proc. Each path describes a different part of the same service.
That gives you a practical way to navigate an unfamiliar installation. To change a system-wide setting, start with /etc. To inspect a running process, start with /proc. To locate persistent service state, investigate /var/lib. And when a familiar directory seems to lead somewhere unexpected, use ls -ld to check for a symbolic link and findmnt -T to identify its filesystem. The directory hierarchy becomes easier to remember when you use it to answer a specific question.
References: Filesystem Hierarchy Standard · Linux file hierarchy.
