Fundamentals 17 min read

Mastering Linux Filesystem Hierarchy: Directories, Paths, and Essential Commands

This guide explains the Linux Filesystem Hierarchy Standard (FHS), the purpose of each top‑level directory, the difference between absolute and relative paths, and provides practical command examples for navigating and managing directories safely and efficiently.

ITPUB
ITPUB
ITPUB
Mastering Linux Filesystem Hierarchy: Directories, Paths, and Essential Commands

FHS Overview

Linux and UNIX use a single‑rooted tree file system where / is the root directory. To avoid the chaotic naming of early UNIX systems, the FileSystem Standard (FSSTND) was introduced in 1994 and later evolved into the FileSystem Hierarchy Standard (FHS), which most Linux distributions follow.

FHS defines what type of files belong in each top‑level directory and how they should be used.

/home

The default home directory for regular users.

/boot

Contains static files required for booting the system, such as the Linux kernel ( vmlinuz ) and, when using grub2 , the /boot/grub2 subdirectory.

Never delete the /boot directory; doing so may render the system unbootable.

/dev

Holds device nodes representing physical and virtual devices. Important examples include:

/dev/hda – primary IDE hard‑disk device

/dev/hdb – secondary IDE device

/dev/tty0 – first virtual console

/dev/tty1 – second virtual console

/dev/sda – first SCSI/SATA device

/dev/lp0 – first parallel port

/etc

Stores system‑wide configuration files (e.g., /etc/passwd , /etc/fstab , /etc/issue ). Only the root user can modify these files; regular users have read‑only access.

/lib

Contains shared libraries required by binaries in /bin and /sbin .

/media

Mount points for removable media such as USB drives, CDs, and DVDs.

/mnt

Temporary mount point for manually mounting additional filesystems.

/opt

Location for optional third‑party software packages. Each package typically gets its own subdirectory (e.g., /opt/sample/bin for binaries).

/proc

A virtual filesystem exposing kernel and process information (e.g., /proc/cpuinfo , /proc/meminfo ). It resides in memory and does not consume disk space.

/sbin

Executable utilities used by the system administrator for system management and recovery. Includes commands such as arp , halt , init , ifconfig , shutdown , etc.

/tmp

Temporary files that are cleared on reboot.

/sys

Another virtual filesystem that provides hardware‑related information, similar to /proc .

/usr

Holds the majority of user‑space software. Key subdirectories:

/usr/bin – user commands (mirrored by /bin on modern systems)

/usr/lib – libraries (linked from /lib )

/usr/local – locally compiled software

/usr/sbin – system administration binaries (linked from /sbin )

/usr/share – architecture‑independent data (man pages, docs, locale files)

/usr/include – C/C++ header files

/usr/src – source code, often /usr/src/linux for kernel sources

/run

Runtime data that used to reside in /var/run in older FHS versions.

/var

Variable data that grows during system operation, such as caches, logs, and spool files. Important subdirectories include /var/log , /var/cache , /var/tmp , and /var/lock .

/srv

Data for services provided by the system (e.g., web or FTP server files).

Absolute and Relative Paths

Absolute paths start at the root ( / ) and specify the full location (e.g., /boot , /usr/local ). Relative paths are expressed from the current working directory (e.g., ../var/log ). Special entries:

. – current directory (or ./ )

.. – parent directory (or ../ )

While relative paths are shorter, absolute paths are more reliable for scripts because they are unaffected by directory changes.

Directory‑Related Commands

cd

Change the current working directory. Four common usages:

cd /path/to/dir   # absolute change
cd ./            # stay in current directory
cd ..            # move to parent directory
cd ~             # go to the user's home directory

pwd

Print Working Directory – displays the absolute path of the current directory. It can also show the path of a specified directory.

mkdir

Create a new directory. Useful options:

-m – set permissions explicitly

-p – create parent directories as needed (recursive) mkdir -m 711 test2 Using -p allows commands like mkdir -p /test1/test2/test3 to create the entire hierarchy in one step.

rmdir

Remove an empty directory. With -p, it can remove a hierarchy of empty directories. To delete non‑empty directories, use rm -r.

mv

Rename or move files and directories. Example: mv oldname newname changes a directory’s name.

PATH Environment Variable

The PATH variable tells the shell where to look for executable files. When you run a command like ls , the system searches each directory listed in PATH for an executable named ls and runs the first match it finds.

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.

LinuxcommandsFilesystempathFHSDirectories
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.