Disk and storage management is a core sysadmin discipline that spans everything from querying free space to building redundant RAID arrays. Linux exposes a rich, layered toolkit β starting with read-only observation commands like df and lsblk, through partitioning tools such as fdisk and parted, on to filesystem creation with mkfs, persistent mounting via /etc/fstab, and flexible logical-volume abstraction through LVM. The key mental model is the storage stack: raw block devices β partition tables β filesystems β mount points β and every command in this cheat sheet operates at one of those layers.
What This Cheat Sheet Covers
This topic spans 18 focused tables and 183 indexed concepts, 137 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Disk Space and Usage Observation
These are the commands you reach for first when diagnosing storage issues or auditing capacity. df reports filesystem-level free/used blocks while du digs into directory trees; together they answer "how full is the disk?" and "what is taking up space?"
| Command | Example | Description | |
|---|---|---|---|
df -h | Reports free and used space on all mounted filesystems in human-readable units (K, M, G, T). | ||
df -hT | β’ Adds a filesystem type column (ext4, xfs, tmpfs) alongside usage data β’ useful to distinguish local vs. network mounts | ||
df -ih | β’ Shows inode usage instead of block usage β’ critical when writes fail despite df -h showing free space | ||
df -hT /home | Checks space and type for the filesystem hosting a specific path. | ||
df -t ext4 -h | Filters output to only the specified filesystem type. | ||
df -x tmpfs -h | β’ Excludes a filesystem type from output β’ removes tmpfs/devtmpfs clutter for a cleaner view | ||
df -h --total | Appends a grand-total row summing all listed filesystems. | ||
df --output=source,size,used,avail,pcent | Selects specific columns to display, useful for scripting. | ||
du -sh /var/log | Prints the total size of a directory in human-readable form (summarize + human). | ||
du -h --max-depth=1 / | β’ Shows sizes for immediate subdirectories only β’ avoids deep recursion noise | ||
du -ah /home/user | Lists sizes of all individual files and directories recursively. | ||
du -ch /var/log/*.log | Prints sizes for matched items plus a grand total line. | ||
du -h --exclude="*.log" /var | Skips files matching a shell glob, useful for excluding logs or caches. | ||
du -shx / | β’ Limits the scan to one filesystem β’ does not cross mount points | ||
du -h --max-depth=1 / sort -hr | Combines du with sort -hr to find the largest directories at one level. |