How to Check Disk Space in Linux (df command)

If your Linux server suddenly crashes, refuses to install new software, or begins throwing bizarre database errors, the very first thing you should check is your hard drive space. Unlike Windows, which frequently displays aggressive “Low Disk Space” warnings on your desktop, a headless Linux server running entirely in the terminal will silently fill up its hard drive until the entire system catastrophically fails.

Fortunately, you can check exactly how much storage space you have remaining across all your hard drives in less than two seconds using a single command: df (Disk Free).

The Basic Command: df

The df command is installed by default on every single Linux distribution. It interrogates the file system and returns a table showing exactly how much space is used and how much is available on every mounted drive.

  1. Open your terminal application.
  2. Type the following command and press Enter:

df

The terminal will instantly print a large table of information. However, you will immediately notice a major problem. The numbers in the “1K-blocks”, “Used”, and “Available” columns are massive, confusing strings of digits (e.g., 102345920). This is because the basic df command reports disk space in individual kilobytes by default, which is completely unreadable for modern humans trying to calculate gigabytes or terabytes.

The Human-Readable Flag (-h)

To fix the unreadable numbers, you must always use the -h (human-readable) flag. This is the single most important flag to memorize when checking disk space.

df -h

When you press Enter, the terminal will print the exact same table, but the numbers will be converted into easily understandable formats:

  • G for Gigabytes
  • M for Megabytes
  • T for Terabytes

How to Read the Output Table

Once you run df -h, you will see a table with several columns. Here is what they actually mean:

  • Filesystem: The physical name of the hard drive or partition (e.g., /dev/sda1 or /dev/nvme0n1).
  • Size: The total, maximum capacity of that specific hard drive (e.g., 500G).
  • Used: Exactly how much data is currently stored on the drive (e.g., 450G).
  • Avail: Exactly how much empty space is remaining (e.g., 50G).
  • Use%: The most important column. It shows a simple percentage of how full the drive is (e.g., 90%). If this number hits 100%, your server will likely crash.
  • Mounted on: Where the drive is located in your file system. The drive mounted on / (the root directory) is your main operating system drive.

How to Check a Specific Folder (The du Command)

The df command is fantastic for checking the overall health of your entire hard drive, but what if your drive is 99% full and you need to figure out which specific folder is hogging all the space?

The df command cannot help you with this. Instead, you must use its sister command: du (Disk Usage). The du command calculates the total size of specific directories.

Just like df, you should always combine du with the -h (human-readable) flag so you can actually understand the output. Additionally, if you run du on a massive directory, it will print thousands of lines of output. You should use the -s (summarize) flag to force it to only print the grand total.

For example, if you want to know exactly how much space the /var/log directory is consuming, you would type:

du -sh /var/log/

The terminal will simply print 12G /var/log/, instantly telling you that your log files have bloated to 12 Gigabytes.

Get the best tech tips delivered straight to your inbox.

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