Chapter Two

Files and the Filesystem

Where everything lives on a Linux box, what a file actually is underneath the name, and how separate disks become one directory tree you can mount, manage, and trust.

6 topics

Linux presents every disk, partition, and pseudo-device as one tree rooted at /. That single namespace is the abstraction the rest of the system is built on, and it only helps you if you know where things belong, what a file is below the name you type, and how storage gets attached to the tree in the first place.

This chapter takes the filesystem apart layer by layer. It maps the standard directories so you know where a binary, a config, or a log should sit, separates the inode from the filename so links and permissions stop being surprising, covers the day-to-day commands for moving data around, and ends at /etc/fstab and the on-disk formats — ext4, XFS, Btrfs, ZFS — that decide how your data is actually stored.

From a filename to bytes on disk
Filenamedirectory entry
Inodemetadata + block map
Data blocksthe contents
Mount pointinto the one tree

Topics in This Chapter

Topic 06
The Filesystem Hierarchy
The single tree rooted at / and the FHS rules behind it: what belongs in /etc, /var, /usr, and /opt, and why /bin and /lib are now symlinks into /usr on modern Debian and Ubuntu.
FilesystemLayout
Topic 07
Files, Inodes, and Metadata
The inode holds a file's real identity — permissions, owner, timestamps, and the block pointers — while the name is just a directory entry pointing at it. Why a filesystem can run out of inodes with disk space to spare, and what stat shows you.
InodesMetadata
Topic 08
Navigating and Managing Files
The core toolset for moving through and reshaping the tree — ls, cp, mv, rm, find — and the sharp edges that bite: mv across filesystems silently copies, and rm has no undo.
CommandsFiles
Topic 09
Links — Hard and Symbolic
A hard link is a second name for the same inode; a symlink is a small file holding a path that can dangle. When to reach for each, why hard links cannot cross filesystems or point at directories, and how the link count decides when data is freed.
LinksInodes
Topic 10
Mounting and /etc/fstab
How a device gets grafted onto the tree with mount, why production entries use a UUID instead of /dev/sda1, and the /etc/fstab mistake that leaves a server hung at boot waiting on a disk that is not there.
Mountingfstab
Topic 11
Filesystem Types
The on-disk formats that decide how your data is stored: ext4 as the Ubuntu default, XFS for large parallel workloads, and the copy-on-write pair Btrfs and ZFS with snapshots and checksums. What each is good and bad at.
Formatsext4 / XFS