Fundamentals 18 min read

Mastering Linux Filesystem Hierarchy: A Complete Guide to FHS Directories

This article provides a comprehensive overview of the Linux Filesystem Hierarchy Standard, explaining the purpose of each top‑level directory, the classification of shareable and variable directories, path types, and practical examples to help readers navigate and manage the Linux file system effectively.

Raymond Ops
Raymond Ops
Raymond Ops
Mastering Linux Filesystem Hierarchy: A Complete Guide to FHS Directories

Introduction

Understanding the Linux filesystem hierarchy is essential for any Linux learner. The root (/) is the top of the tree, and the Filesystem Hierarchy Standard (FHS) defines the purpose of each directory.

Four Types of Directories

FHS classifies directories as shareable/static, unshareable/static, shareable/variable, and unshareable/variable. Key examples include:

/usr – software location (shareable, static)

/etc – configuration files (unshareable, static)

/opt – third‑party software (shareable, static)

/boot – boot files (unshareable, static)

/var/mail – user mailboxes (shareable, variable)

/var/run – runtime data (unshareable, variable)

/var/spool/news – news groups (shareable, variable)

/var/lock – lock files (unshareable, variable)

Key Top‑Level Directories

/ (root) – entry point of the filesystem, contains essential files for booting and system recovery. It should reside on a small partition.

/usr – “Unix Software Resource”, holds shareable and static data such as installed software. Subdirectories include /usr/bin, /usr/lib, /usr/include, /usr/local, /usr/share, etc.

/var – variable data that grows during system operation, such as logs, caches, mail, and lock files. Subdirectories include /var/log, /var/lib, /var/spool, /var/cache, and more.

Other Important Directories

/bin, /sbin, /lib, /dev, /home, /media, /mnt, /opt, /root, /tmp, /proc, and /sys each serve specific purposes, from essential binaries to device files, user homes, removable media, temporary files, and virtual filesystems.

Path Types

Absolute paths start with “/” (e.g., /var/log), while relative paths are based on the current directory (e.g., ./run.sh, ../var/spool).

Examples

Changing directories using absolute and relative paths:

<code>cd /var/spool/mail
cd ../cron</code>

Running a script in the current directory requires the “./” prefix:

<code>./run.sh</code>
LinuxDirectory StructureOperating SystemFilesystemFHS
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

login 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.