How to Use the Linux df Command to Check Disk Space

The Silent Server Crash

One of the most common reasons a healthy Linux server suddenly crashes is entirely preventable: it simply ran out of hard drive space. When a disk hits 100% capacity, databases cannot write new records, log files cannot save errors, and the entire operating system grinds to a halt.

If you are managing a Windows or Mac computer, you can just open the file explorer and look at the visual progress bar under the “C: Drive.” On a headless Linux server, you do not have a graphical interface. You must use the terminal to ask the system exactly how much space is left.

The tool for this job is the df (Disk Free) command. It is a fundamental system administration tool that instantly audits every single hard drive connected to your server and reports their exact capacity and usage.

The Basic Command (And Why It’s Hard to Read)

If you log into your terminal and type the command by itself:

df

Linux will print a table, but it will look like absolute gibberish to a human. The output will show columns of massive, ten-digit numbers (e.g., 102438592). This happens because, by default, df reports disk space in 1-Kilobyte blocks. Nobody calculates server storage in kilobytes.

The Human-Readable Flag (-h)

To make the output instantly understandable, you must append the -h (human-readable) flag. This tells Linux to do the math for you and present the data in Megabytes (M), Gigabytes (G), and Terabytes (T).

df -h

When you press Enter, you will receive a clean, easy-to-read table. Let’s break down the most important columns in that table.

Understanding the Output Columns

  1. Filesystem: This is the physical (or virtual) hard drive itself. Your main system drive usually looks something like /dev/sda1 or /dev/nvme0n1p1. (You can ignore filesystems that say tmpfs or udev; these are temporary virtual drives in RAM).
  2. Size: The total maximum capacity of the drive (e.g., 50G).
  3. Used: How much space is currently taken up by files (e.g., 45G).
  4. Avail: Exactly how much free space you have left before the server crashes (e.g., 5.0G).
  5. Use%: The most critical column. It shows the usage as a simple percentage. If you see a drive at 98%, you have an immediate emergency.
  6. Mounted on: Where in the file system this drive is located. / is the absolute root of your server. If you have an external backup drive plugged in, it might be mounted at /mnt/backups.

Targeting a Specific Drive or Folder

If your server has five different hard drives attached to it, running df -h will print all of them, which can be cluttered. If you only care about the drive that holds your web application, you can point the command directly at that folder.

df -h /var/www/html

Linux will look at that specific folder, figure out which physical hard drive it lives on, and print the capacity stats for only that specific drive.

Conclusion

You cannot manage a server if you do not know how much space it has left. By habitually running the df -h command, you can instantly monitor your disk capacity in a human-readable format, allowing you to delete old logs or upgrade your storage long before a catastrophic 100%-full crash occurs.

Related posts

  1. Essential Linux Terminal Keyboard Shortcuts to Work Faster
  2. How to Find Large Files and Directories in Linux
  3. How to Create and Extract ZIP Files in the Linux Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.