Mastering Disk Usage Analysis With ncdu

Search for a command to run...

No comments yet. Be the first to comment.
A short story about my life as a DevOps engineer It's 2:47 PM. I'm staring at a staging environment that swears it's pointing to the new load balancer. The DNS change was made an hour ago. TTL was 300
Day 1 Day one at the new gig. I'm a DevOps engineer, which means I spend most of my professional life automating away other people's toil. So it was genuinely humbling when IT handed me a fresh M2 Mac
Forgot your spreadsheet password? Resolve how to remove sheet, workbook, and VBA protections.

Managing Kubernetes clusters, contexts, and namespaces can be time-consuming. But fear not! I’ve got you covered with KubeKit smart tools: kubectl (with k alias), helm, kustomize, kc, and kn. These to

This repository provides a GitOps approach to maanage your DNS records live in Git, changes are peer-reviewed, and deployments are automated through CI/CD. When the dashboard is down, your DNS config is still version-controlled and ready to push to a...

As a systems engineer, understanding disk usage is not just beneficial — it's essential for maintaining the health and performance of your servers. In this guide, we’ll explore how to efficiently analyze your filesystem using ncdu along with a few other reliable command-line tools.
ncdu?ncdu (NCurses Disk Usage) is a lightweight, interactive disk usage analyzer.
It gives you a fast and easy way to identify which directories and files are hogging your disk space — all through a simple terminal interface.
ncduGetting ncdu up and running is quick:
On Debian/Ubuntu-based systems:
sudo apt install ncdu
On Red Hat/CentOS/Fedora systems:
sudo yum install ncdu
ncdu to Analyze Filesystem UsageRunning ncdu is super straightforward — just point it at a directory:
ncdu /path/to/directory
One of ncdu's killer features is the -x option, which restricts the scan to a single filesystem:
ncdu -x /var/log
This is really handy when you want to avoid crossing into mounted volumes or other partitions accidentally.
ncdu InterfaceWhen you launch ncdu, you can interact with it using your keyboard:
Arrow keys: Navigate through the directories
Enter: Dive into a directory
d: Delete a file or directory (⚠️ use carefully)
q: Quit the program
It’s intuitive enough that you’ll be flying through your filesystem in minutes.
While ncdu is amazing for interactive exploration, the good old command line has some other tricks up its sleeve.
df — Display Free Disk SpaceThe df command shows you disk space usage and free space across all mounted filesystems:
df -h
The -h flag makes it human-readable (i.e., shows sizes in KB, MB, GB).
To focus on a specific directory:
df -h /var
du — Estimate File and Directory SizesThe du command is perfect for quick checks:
du -sh /var/log
-s: Display only the total size
-h: Human-readable format
Want a breakdown of subdirectories?
du -h --max-depth=1 /var/log | sort -hr
This will show you the size of each immediate subdirectory, sorted from largest to smallest.
find — Locate Large FilesSometimes you just need to hunt down the big files:
find /var -type f -size +100M -exec ls -lh {} \; | sort -k5 -hr
This finds files larger than 100MB and lists them, sorted by size.
| Tool | Best Use Case |
ncdu | Interactive exploration and cleanup |
df | Quick snapshot of disk space across filesystems |
du | Detailed file/directory size summaries (great for scripting) |
find | Laser-targeted search for huge files |
Keeping an eye on your disk usage is essential for any serious server management strategy.ncdu is an awesome tool for interactive, detailed analysis — especially when paired with options like -x to stay within boundaries.
But don't sleep on the classics either: df, du, and find each bring their own strengths to your sysadmin toolkit.
By combining these tools, you’ll stay ahead of disk space problems before they turn into full-blown outages. 🚀