How to Check Disk Usage in Linux Using df and du

When a Linux server or workstation starts running low on storage, the first challenge is figuring out exactly where the space went. Linux provides two built-in command-line tools for this: df (Disk Free) for checking overall partition usage, and du (Disk Usage) for pinpointing which specific directories or files are consuming the most space. Here is how to use both effectively.

Checking Overall Disk Space with df

The df command gives you a high-level view of your entire file system — how much space each mounted partition has in total, how much is used, and how much is free.

The most useful version of this command is:

df -h

The -h flag stands for “human-readable” and converts the output from raw disk blocks into units you can actually read, such as GB and MB. The output will show each mounted file system, its total size, amount used, amount available, the percentage used, and where it is mounted.

Finding Which Directories Are Using the Most Space with du

Once you know a partition is nearly full, the next step is identifying which directories are responsible. This is where du is useful.

To check the total size of a specific directory:

du -sh /path/to/directory

The -s flag summarizes the total (instead of listing every file inside), and -h makes the output human-readable.

To see which immediate subdirectories inside a folder are the largest, use:

du -h --max-depth=1 /var | sort -h

The --max-depth=1 flag limits the output to one level deep so you are not overwhelmed with thousands of lines. Piping the result into sort -h arranges the output from smallest to largest, so the biggest directories appear at the bottom where you can immediately see them.

Quick Reference

GoalCommand
How much space is left on my disk?df -h
How large is a specific folder?du -sh /path/to/folder
Which subfolder is taking the most space?du -h --max-depth=1 /path | sort -h

If you find du output difficult to read in a long list, consider installing ncdu, an interactive terminal-based disk usage viewer that lets you navigate through directories with your keyboard arrows and instantly see which folders are the largest.

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.

Receive our best articles and tips delivered straight to your inbox.