Monitoring Disk Usage in Linux with ncdu and df
Posted October 28, 2024

When you’re managing servers, keeping an eye on disk space is like making sure there’s enough fuel in the tank. If you don’t, you’ll eventually hit empty—except in this case, it means crashing applications or the dreaded “disk full” errors.
Fortunately, Linux has a couple of great tools that make monitoring disk usage quick and easy: df
and ncdu
. Let’s walk through how these two can help keep your servers running smoothly without the storage headaches.
A Quick Overview with df
When you need a fast check on how much space is left on your system, the df -h
command is your go-to. It’s simple, effective, and gives you all the information you need in a human-readable format (no decoding cryptic block sizes here).
Here’s how it works:
df -h
This command gives you an output like this:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 20G 28G 42% / tmpfs 1.0G 100M 900M 10% /run /dev/sda2 100G 60G 35G 63% /home
Filesystem: Your drive or partition.
Size: Total available space.
Used: Space already in use.
Avail: Free space still available.
Use%: Percentage of space used.
Mounted on: Where the file system is accessible on your system.
In short, df -h
gives you a snapshot of disk usage across all mounted file systems, making it easy to see at a glance if you’re running out of space.
Dig Deeper with ncdu
While df -h
is great for an overview, what if you want to know exactly where all that space is going? That’s where ncdu
comes in. It’s an interactive tool that allows you to browse through your file system and see which directories and files are taking up the most room.
To get started with ncdu, install it first:
sudo apt install ncdu # For Debian/Ubuntu sudo yum install ncdu # For RHEL/CentOS
Once it’s installed, use it like this:
ncdu /path/to/directory
You’ll be presented with a list of files and directories sorted by size, and you can easily navigate through them using your arrow keys. Want to delete something right there? Just hit d! It’s a great tool when you need to free up space quickly and want to avoid guesswork.
Why Use Both?
Here’s why these two tools work so well together:
df -h
gives you the big picture—what’s happening across all your file systems.
ncdu is for the details—drilling down into specific directories to find what’s eating up your space.
Together, they make monitoring and managing disk usage on your Linux servers simple and efficient.
Wrapping Up
Monitoring disk usage should be part of your routine server maintenance. Tools like df -h
and ncdu
help you catch issues before they become real problems, like running out of space at the worst possible moment.
Add them to your toolbox, use them regularly, and your servers will thank you. After all, a little disk space management can go a long way in keeping everything running smoothly.
Looking for more tips? Stay tuned as we continue sharing useful tools to make your server management life easier.

Paul Shepherd
Paul oversees all technical aspects at Zaltek, focusing on delivering software solutions for our clients. He leads the tech team and manages our software development projects. Paul works with clients to solve challenges and implement innovative technologies.