Fundamentals 32 min read

Master Linux Filesystem Hierarchy: Complete Guide to FHS, Directories, and File Types

This article explains the Linux Filesystem Hierarchy Standard, the purpose and content of top‑level directories such as /, /usr and /var, details key subdirectories, distinguishes absolute and relative paths, and describes Linux file types, extensions, naming limits and attribute inspection commands.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Filesystem Hierarchy: Complete Guide to FHS, Directories, and File Types

Overview

Understanding the Linux directory structure is essential for anyone learning the operating system, because the layout determines where configuration files, binaries, user data and system resources reside.

Filesystem Hierarchy Standard (FHS)

The FHS was created by a community group to standardise where software and data should be placed, making systems interchangeable and easier to manage. It classifies directories by shareability (shareable vs. unshareable) and mutability (static vs. variable).

Shareable & static : /usr (software) and /opt (third‑party packages)

Unshareable & static : /etc (configuration files)

Shareable & variable : /var/mail (user mailboxes)

Unshareable & variable : /var/run (runtime data)

Top‑level directories

The root directory / is the entry point of the whole tree. Two important sub‑trees are: /usr – holds the majority of installed software; comparable to Windows C:\Program Files . /var – contains data that changes during normal operation, such as logs and caches.

Key directories under /

/bin

– essential binaries usable in single‑user mode. /boot – kernel and bootloader files. /dev – device nodes (character and block devices). /etc – system configuration files (readable by all, writable only by root). /home – users’ home directories. /lib – libraries needed by binaries in /bin and /sbin. /media – mount points for removable media. /mnt – temporary mount points. /opt – optional third‑party software. /root – root user’s home directory. /sbin – system administration binaries. /srv – data for network services (e.g., /srv/www). /tmp – temporary files, cleared at boot.

Additional system directories

/lost+found

– created by ext2/3/4 for recovered fragments after filesystem errors. /proc – virtual filesystem exposing kernel and process information. /sys – another virtual filesystem for hardware and driver data.

Partitioning advice

The FHS recommends keeping /, /etc, /bin, /dev, /lib and /sbin on the same (preferably small) partition, because they are required during boot and recovery.

/usr details

/usr

is shareable and static. Recommended sub‑directories include: /usr/X11R6 – X Window System files. /usr/bin – most user‑available commands. /usr/include – C/C++ header files. /usr/lib – libraries for applications; on 64‑bit systems /usr/lib64 may appear. /usr/local – locally compiled software. /usr/sbin – system daemons and server utilities. /usr/share – architecture‑independent data (man pages, docs, time‑zone files). /usr/src – source code, including kernel sources under /usr/src/linux.

/var details

/var

stores variable data that grows after installation. Important sub‑directories: /var/cache – application cache files. /var/lib – persistent state data (e.g., /var/lib/mysql). /var/lock – lock files to prevent concurrent access. /var/log – system and application logs. /var/mail – user mailboxes (often linked to /var/spool/mail). /var/run – PID files for running services. /var/spool – queued data such as mail, print jobs, or cron files.

Path types

Absolute paths start with / (e.g., /home/user/.bashrc). Relative paths are expressed from the current directory (e.g., ../var/log). Example commands:

cd /var/log      # absolute
cd ../var/log    # relative from /home

Linux file types

Common file types include:

Regular file – ordinary data file (first character - in ls -l output).

Directory – container for other files (first character d).

Character device – e.g., /dev/tty (first character c).

Block device – e.g., /dev/sda1 (first character b).

Socket – inter‑process communication endpoint (first character s).

Symbolic link – shortcut to another file (first character l).

FIFO (named pipe) – first‑in‑first‑out queue (first character p).

Example listings:

[root@localhost ~]# ls -al /dev/tty
crw-rw-rw- 1 root tty 5, 3 15:11 /dev/tty
[root@localhost ~]# ls -al /dev/sda1
brw-r----- 1 root disk 8, 1 07:11 /dev/sda1

File extensions

Linux does not rely on extensions for execution; the executable bit in permissions determines run‑ability. Nevertheless, common extensions help identify file purpose, e.g., .sh for shell scripts, .tar.gz for compressed archives, .html for web pages.

File name limits

Maximum length of a single filename: 255 characters.

Maximum length of a full path (including /): 4096 characters.

File attributes

The command ls -lih displays:

inode number

file type and permission bits

hard‑link count

owner

group

size

last access/modification timestamps

filename

Example output:

2095112 -rw-r--r-- 1 root root 296K 11-13 06:03 log2012.log

Interpretation: inode 2095112, regular file, readable/writable by owner, readable by group and others, size 296 KB, owned by root, last modified at 06:03.

Conclusion

Mastering the Linux filesystem hierarchy, path conventions, file types and attribute inspection equips users and administrators to navigate, configure and troubleshoot systems efficiently.

Linux directory tree diagram
Linux directory tree diagram
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.

Directory StructureFHSFile Types
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.