How to Use the Linux df Command to Check Disk Space Usage

Running out of disk space on a Linux server can cause catastrophic failures. If the root partition fills up entirely, the operating system can no longer write to system logs, databases will abruptly crash, and you may even find yourself locked out of SSH access entirely. To prevent these silent failures, system administrators must regularly monitor storage capacity. While there are many complex monitoring tools available, the quickest and most reliable way to check your available storage directly from the command line is by using the Linux df (disk free) command.

Basic Disk Free Output

The df command queries the Linux kernel for the total size, used space, and available space of every mounted file system on the machine.

  1. Open your terminal application.
  2. Type the command: df
  3. Press Enter.

The terminal will output a multi-column table displaying all connected drives (like /dev/sda1) and virtual file systems (like tmpfs). However, you will immediately notice a problem: the “Size”, “Used”, and “Available” columns are displayed in raw 1K blocks (kilobytes). A string of numbers like 482938472 is incredibly difficult for a human to read quickly.

Reading the Output in Human-Readable Format

To make the output legible, you must always run the command with the -h (human-readable) flag. This forces df to automatically calculate the numbers and display them in easily recognizable formats like Megabytes (M), Gigabytes (G), or Terabytes (T).

df -h

The output will now look much cleaner:

  • Filesystem: The name of the hardware partition (e.g., /dev/nvme0n1p2).
  • Size: The total storage capacity of the drive (e.g., 500G).
  • Used: The amount of space currently filled by files (e.g., 45G).
  • Avail: The remaining empty space (e.g., 455G).
  • Use%: A percentage showing how full the drive is (e.g., 9%). This is the most critical metric for spotting impending storage disasters.
  • Mounted on: The directory where the drive is attached to the system (e.g., / for the root OS drive, or /mnt/backup for an external drive).

Checking a Specific Directory

If you run df -h on a complex server, you might be overwhelmed by dozens of virtual file systems, loop devices (from Snap packages), and network drives. If you only want to check the free space of the primary hard drive where a specific folder resides, you can pass the folder path directly to the command.

For example, to check the available capacity of the drive that holds your home directory:

df -h /home/user/

The command will filter out the noise and return exactly one line of output showing the capacity of the specific partition that houses that directory.

Get the best tech tips delivered straight to your inbox.

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