Fundamentals 19 min read

Mastering Linux Filesystem Hierarchy: A Complete Guide to FHS Directories

This article explains the Linux Filesystem Hierarchy Standard (FHS), detailing the purpose and typical contents of each top‑level directory such as /, /usr, /var, and their subdirectories, while clarifying concepts like static vs. variable, shareable vs. unshareable, and absolute versus relative paths.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Linux Filesystem Hierarchy: A Complete Guide to FHS Directories

Introduction

For every Linux learner, understanding the directory structure is essential. The Linux filesystem appears as a tree rooted at /, the root directory.

Filesystem Hierarchy Standard (FHS)

The FHS was created by a community of Linux enthusiasts to standardize where files should be placed, making systems portable and easier to maintain.

Four Types of Directories

Shareable : directories that can be mounted and shared across systems (e.g., /usr, /var/mail).

Unshareable : machine‑specific files such as device nodes and sockets (e.g., /etc, /dev).

Static : rarely changed data that follows the distribution (e.g., libraries, documentation).

Variable : frequently changing data like logs, mail spools, lock files.

Top‑Level Directories

/ (root) : entry point of the filesystem; contains essential boot files and should reside on a small partition.

/usr : “Unix Software Resource”, holds shareable and static software; analogous to Windows C:\Windows and Program Files.

/var : “variable”, stores data that grows during operation such as logs, caches, mail, and run‑time files.

Important Subdirectories

/bin : essential user commands usable in single‑user mode.

/boot : kernel and bootloader files.

/dev : device files presented as files.

/etc : system configuration files (readable by all, writable only by root).

/home : user home directories.

/lib : libraries needed by binaries in /bin and /sbin.

/media and /mnt : mount points for removable media.

/opt : third‑party optional software.

/root : home directory of the root account.

/sbin : system binaries for administration.

/srv : data for network services.

/tmp : temporary files, cleared at boot.

/lost+found : recovery directory for ext2/3 filesystems.

/proc and /sys : virtual filesystems exposing kernel and hardware information.

Path Types

Absolute paths start with / (e.g., /home/user/.bashrc). Relative paths are expressed from the current directory (e.g., ./script.sh or ../var/log).

Examples

To move from /var/spool/mail to /var/spool/cron you can use:

cd /var/spool/mail
cd ../cron

Running a script in the current directory requires ./ before the script name, e.g., ./run.sh.

Understanding the FHS helps developers place files correctly, simplifies system administration, and ensures compatibility across Linux distributions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxDirectory StructureOperating SystemFilesystemFHS
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.