When operating a Linux server or desktop, running out of disk space can cause catastrophic system failures. Databases will crash, logs will fail to write, and applications will refuse to launch. Monitoring your storage capacity is a fundamental administrative task, and the fastest way to check your available disk space directly from the terminal is by using the df command.
What is the df Command?
The df command stands for “disk free.” It reads the partition tables of your Linux system and reports the total amount of disk space, the amount currently used, and the amount remaining available on every mounted file system.
To see how it works, simply open your terminal and type:
df
When you press Enter, you will immediately notice a problem: the output is a massive wall of confusing, multi-digit numbers. By default, df reports disk space in 1-kilobyte blocks, which is nearly impossible for a human to read quickly when dealing with modern 500-gigabyte hard drives.
Using the Human-Readable Flag (-h)
To make the output useful, you must always pair the df command with the -h (human-readable) flag.
df -h
The -h flag instructs the command to dynamically convert those massive kilobyte blocks into Megabytes (M), Gigabytes (G), and Terabytes (T). This makes the output instantly understandable at a glance.
Understanding the Output Columns
When you run df -h, the terminal will print a clean table with six columns. Here is exactly how to read them:
- Filesystem: The actual name of the partition or drive (e.g.,
/dev/sda1is usually your primary hard drive, whiletmpfsrepresents temporary files stored in your RAM). - Size: The total storage capacity of that specific partition (e.g., 250G).
- Used: The exact amount of storage currently occupied by files (e.g., 100G).
- Avail: The remaining free space you have left to use (e.g., 150G).
- Use%: The percentage of the drive that is full. If you see this number hit 90% or higher, it is time to start deleting files or upgrading your server.
- Mounted on: This tells you where the drive is accessible in the Linux directory structure.
/represents the root directory (your main operating system drive), while/mnt/backupmight represent an external hard drive.
Checking a Specific Directory or Drive
If you have dozens of drives and network mounts connected to your Linux machine, the output of df -h can still be overwhelming. If you only want to know the free space on the drive that houses a specific directory (like your web server folder), you can pass that path directly to the command.
df -h /var/www/html
This command will filter out everything else and print a single line showing the exact disk space statistics for the partition where the /var/www/html directory lives.