When managing a Linux server, one of the most critical daily tasks is monitoring storage capacity. If a primary partition fills up completely, databases will crash, system logs will fail to write, and the server may become completely unresponsive. To instantly audit the storage capacity across all mounted filesystems and drives, you must use the df (disk free) command.
How the df Command Works
Running the df command by itself in the terminal will immediately print a comprehensive table detailing the storage statistics for every single filesystem currently attached to the operating system.
df
The resulting table contains several critical columns of information:
- Filesystem: The actual hardware device name (e.g.,
/dev/sda1) or virtual mount point. - 1K-blocks: The total storage size of the partition, calculated in 1-kilobyte blocks.
- Used: The amount of storage currently consumed.
- Available: The remaining free space.
- Use%: A simple percentage showing how full the partition is (e.g.,
85%). - Mounted on: The directory where the filesystem is accessible (e.g.,
/for the root drive, or/mnt/backupfor an external drive).
Enabling Human-Readable Output
While the default output is accurate, reading the total size in “1K-blocks” is incredibly difficult for humans. Trying to mentally calculate whether a 9-digit number represents gigabytes or terabytes is frustrating and prone to error.
To fix this, you should always append the -h (human-readable) flag to the command.
df -h
The -h flag instructs the utility to automatically convert those raw block numbers into familiar sizes, appending a G for Gigabytes, M for Megabytes, or T for Terabytes. The total size column will now clearly display a value like 250G, making it instantly obvious how large the drive is and how much space is left.
Filtering by Specific Filesystems
Modern Linux operating systems (like Ubuntu) utilize dozens of temporary, virtual filesystems (like tmpfs and squashfs loops for snap packages) to operate. When you run df -h, these virtual drives heavily clutter the output table, making it difficult to find the actual physical hard drives you care about.
To filter the noise, you can use the -t (type) flag to instruct the command to only display specific types of filesystems. Physical Linux partitions are most commonly formatted as ext4.
df -h -t ext4
This command will strip away all the virtual temporary drives and only print the storage statistics for your actual, physical ext4 hard drives, providing a much cleaner and actionable report.