Is Your VPS Running Low on Space and You’ve Been Deleting Files, Yet Your Disk Is Still Nearly Full? But where is all this storage going? To understand where all that space may be going, use ncdu like an expert to track disk usage like never before.
Have you been struggling to identify what’s eating up your server’s hard drive space? Well, help is at hand: the ncdu tool provides an effective solution.
Let’s dive into what ncdu is, its benefits, and how to utilize it effectively on a VPS server.
What Is ncdu and Why Should You Utilize It?
Table of Contents
ncdu stands for NCurses Disk Usage. It’s a fast, text-based disk usage viewer that runs in your terminal. It makes viewing disk usage simple and far more insightful than using the du
command alone.
Instead of scrolling through endless lines of output, ncdu
provides an easily navigable interface that displays which folders or files are taking up the most space.
Why it is awesome:
- Lightweight but effective — no bloated GUI required.
- Works with nearly every Linux distro.
- Makes finding large files a snap!
Install ncdu on Your VPS
Installation takes just seconds. Open up a terminal session and enter these commands based on your Linux distribution:
For Ubuntu/Debian:
sudo apt update
sudo apt install ncdu
For CentOS/RHEL:
sudo yum install epel-release
sudo yum install ncdu
For Fedora:
sudo dnf install ncdu
For Arch Linux:
sudo pacman -S ncdu
Using ncdu to Analyze Disk Usage
Once installed, just run:
ncdu /
This tells ncdu to inspect all files on your server’s root directory (that’s everything).
If you only want to scan a particular folder — for example, your home directory or /var
— simply run:
ncdu /var
You’ll see a text-based interface showing folders ranked by size. Use the arrow keys to navigate:
- Up/Down: Navigate through the list
- Right: Enter a directory
- Left: Go back
- d: Delete selected file or folder
- q: Quit
⚠ Warning: Be cautious with the d
key — once something is deleted, it’s gone for good. Only delete items you’re absolutely sure about.
Real-World Example: Cleaning Out /var
One of the biggest space hogs on most servers is the /var
directory. Logs, caches, and package managers love to dump data here — and it often gets forgotten.
Try this:
ncdu /var
You might find massive log files in /var/log
or old package archives in /var/cache/apt
. With ncdu, cleaning them up is fast and simple.
Bonus Feature: Exclude Mount Points or Directories
Want to skip over mounted drives or external filesystems? Use the -x
flag to stay within a single filesystem:
ncdu -x /
This is especially helpful if you don’t want network drives or external disks included in your scan.
Alternate: Create and Save a Report to Share
You can even generate a portable report using:
ncdu -o report.json /
Then open it later (or send it to someone else) using:
ncdu -f report.json
Final Thoughts
Optimizing disk space on a VPS doesn’t need to be complicated. With ncdu, you get a visual breakdown of what’s consuming your drive — and you can clean it up with just a few keystrokes.
So the next time your VPS runs low on space, don’t panic. Fire up ncdu
and take back control of your storage like a pro.
Happy cleaning!