Skip to content

File System Hierarchy

First PublishedByAtif Alam

The Linux file system is a single tree rooted at /. The Filesystem Hierarchy Standard (FHS) defines the purpose of major directories. Understanding this layout and how filesystems work helps you navigate, troubleshoot full disks, and reason about where the kernel and boot files live (see Boot Process for /boot and the kernel).

DirectoryPurpose
/Root of the tree; contains top-level directories.
/binEssential user binaries (e.g. ls, cat). Often a symlink to /usr/bin.
/etcSystem-wide configuration (e.g. /etc/fstab for mounts).
/varVariable data: logs, caches, spool files.
/usrUser programs and read-only data; /usr/bin, /usr/lib, /usr/share.
/homeUser home directories.
/tmpTemporary files; often cleared on reboot.
/devDevice files (block and character devices).
/procPseudo-filesystem: process and kernel info (see below).
/sysPseudo-filesystem: kernel objects, devices, drivers (see below).
/mntTraditional mount point for temporarily mounted filesystems.
/mediaMount points for removable media.

/proc and /sys are not on disk; the kernel serves them. They expose runtime state:

  • /proc — Per-process directories (/proc/<pid>/), system info (/proc/meminfo, /proc/cpuinfo), and more. For example, /proc/mounts lists currently mounted filesystems.
  • /sys — Kernel objects, device topology, and tunables. Used by udev, sysfs, and tools like lsblk.

A filesystem stores file data and metadata on a block device (disk or partition). Key concepts:

  • Superblock — Stored at a fixed place; describes the filesystem (type, block count, block size, inode count).
  • Inodes — One per file; store metadata (permissions, size, timestamps, pointers to data blocks). The filename is not in the inode; it lives in directory data.
  • Directories — Special files whose content is a list of names and inode numbers. Lookup: resolve name → inode number → inode → data blocks.
  • Blocks — Units of space for file data; size is fixed (e.g. 4 KiB). Large files use multiple blocks; indirect blocks can extend the pointer chain.
  • Mounting — A filesystem on a device is attached to a directory (mount point). The root filesystem is mounted at / during boot; others are mounted per /etc/fstab or manually.

Common Linux filesystems: ext4 (default on many distros), XFS, btrfs. To see types: df -T or file -s /dev/sda1.

Reading a file (e.g. cat file.txt): open the directory, find the inode for file.txt, open that inode, read the block pointers, then read the data blocks from disk.

ToolPurpose
ls, treeList directory contents.
statFile/inode metadata.
df, duDisk space (filesystem and directory usage).
mount, umount, findmntMount and list mounts.
/etc/fstabStatic mount configuration.
lsblk, blkidBlock devices and UUIDs.
lsofOpen files (and which process has them).
cat, less, grepView and search file content.
uname -rKernel release (e.g. for matching kernel modules or docs).
  • Use ls -la and tree to explore. stat <path> shows inode, size, blocks, and timestamps.
  • Which disks are mounted: findmnt, mount, df, or read /proc/mounts. lsblk shows the block device tree and mount points.

When a drive is full, applications may fail with “No space left on device”. Check:

  1. Filesystem usagedf -h shows usage per mounted filesystem. High percentage or 100% means the filesystem is full.
  2. Directory usagedu -sh /var/* (or other suspect directories) finds large trees. du -h --max-depth=1 helps narrow down.
  3. Largest filesfind /var -type f -exec du -h {} + 2>/dev/null | sort -rh | head -20 (adjust path). Alternatively use ncdu if available.

Freeing space: remove or rotate logs, clear caches, delete unneeded files, or extend the filesystem if using LVM.

  • Mount manually: mount /dev/sda1 /mnt (or by UUID with mount UUID=... /mnt). Unmount with umount /mnt.
  • /etc/fstab defines mounts at boot. See Boot Process for how the root filesystem and fstab are used during boot.
  • lsblk and blkid show block devices and filesystem labels/UUIDs.
  • Examples of pseudo-files: cat /proc/meminfo, cat /proc/uptime, ls /sys/block.
  • lsof lists open files per process. lsof +D /var shows processes with files under /var. Useful when a “device busy” error prevents unmounting — find and close the process.