Beginner 20 min readModule: Module 2: File System Hierarchy (FHS) & Inode Mechanics
File System Hierarchy Standard (FHS) & Inodes
Explore the single root directory tree, virtual filesystems, inode metadata structures, and the difference between hard links and symbolic links.
What You Will Learn in This Lesson
- The purpose of essential top-level FHS directories (/bin, /etc, /var, /tmp, /opt, /home)
- Virtual memory filesystems: /proc (process data) and /sys (hardware device tree)
- What an Inode is and how files are indexed on disk
- Creating and managing Hard Links vs Symbolic (Soft) Links with ln
Introduction & Core Concept
Unlike Windows which mounts distinct drives on separate drive letters (C:, D:), Linux organizes everything into a single inverted hierarchical tree starting at the root directory (/). Devices, configuration files, network sockets, named pipes, and running processes all appear as files in this unified directory hierarchy—adhering to the Unix philosophy that 'Everything is a file.'
WHY DOES THIS MATTER IN THE REAL WORLD?
Knowing where system logs (/var/log), service configurations (/etc), temporary files (/tmp), and kernel parameters (/proc/sys) reside is essential for debugging server outages, managing disk storage, and preventing disk exhaustion incidents.
Syntax & Structure
bash
ls -lailn -s target_file symlink_nameln target_file hardlink_namedf -hdf -iExploring Inodes, Hard Links, and Soft Links
bashbash
12345678910111213141516171819202122232425#!/usr/bin/env bash# Inode and Link Mechanics Demonstrationmkdir -p /tmp/linux_lab && cd /tmp/linux_lab# Create original source fileecho "Production Database Secret" > original.txt# 1. Create a Hard Link (Shares the exact same Inode)ln original.txt hardlink.txt# 2. Create a Symbolic Soft Link (Contains a pointer path, new Inode)ln -s original.txt symlink.txt# Display Inode numbers (Column 1) and link counts (Column 3)ls -lai original.txt hardlink.txt symlink.txtecho -e "=== Modifying original.txt updates both ==="echo "Appended Secret Line" >> original.txtcat hardlink.txtecho -e "=== Inode Consumption Verification ==="df -i /tmp | awk 'NR==1 || NR==2'
Line-by-Line Technical Breakdown
1FHS Core Directory Roles: /etc stores static system configuration files (e.g., /etc/hosts, /etc/fstab). /var stores variable data that changes during operation (e.g., /var/log, /var/lib/docker). /proc and /sys are synthetic in-memory virtual filesystems generated on the fly by the Linux kernel.
2Inode Architecture: An Inode (Index Node) stores file metadata including file type, size, owner UID, group GID, permission bits, timestamps (ctime, mtime, atime), and pointers to data blocks on disk. Noticeably, the file name is stored inside directory entry data blocks, not within the inode itself.
Try It Yourself (Interactive Editor)
Modify the code in real-time and click Run to test live browser output and console logs.
Intelligent Code Runner & Live Sandbox[BASH]
BASH SOURCE EDITOR
Interactive Live CodeCommon Mistakes & How to Avoid Them
#1: Creating a hard link to a directory or across different mounted disk partitions.
Hard links cannot cross filesystem boundaries or point to directories because inode numbers are unique only within a single filesystem partition.
Incorrect / Antipattern
ln /mnt/storage/data.csv /home/user/data.csvCorrect / Professional Solution
ln -s /mnt/storage/data.csv /home/user/data.csvIndustry Best Practices & Professional Standards
- Use symbolic links (ln -s) for cross-filesystem aliases and configuration switching.
- Monitor both disk space (df -h) and inode capacity (df -i) on logging and upload servers.
- Store third-party applications in /opt and machine-local static configurations in /etc.
Lesson Summary & Core Takeaways
- Linux structures all storage, devices, and virtual tables under a single unified root (/).
- Inodes store file metadata and disk block pointers, while directory records link filenames to inodes.
- Hard links share inode numbers within a partition; soft symlinks store path references.