Using ncdu to Troubleshoot Disk Usage and Remove Files

Using ncdu to Troubleshoot Disk Usage and Remove Files

Quickly find what's eating all of your storage space using the simple terminal tool ncdu. 🐧

Have you ever checked your Linux system stats and realized your hard drive or raid array is nearly full? You can easily figure out what's eating all that space using an underrated tool called ncdu. This tool has helped me find logs that were quickly taking up space on my boot drive. I rectified the situation by setting the logs to rotate and auto prune. Without this tool I wouldn't have known what was causing the drive to fill up so fast. Sure, it seems like a rookie mistake, but things like this can easily be overlooked.

What is ncdu?

ncdu is a terminal disk utility for Unix systems. It allows you to browse directories on your system with arrow keys while displaying the size of files and folders in a list format. ncdu uses a text-based user interface under the [n]curses programming library.

Installing ncdu is simple. Pop open your favorite terminal app (mine is Tabby) and just run the command: apt install ncdu

When you first launch ncdu by typing the command ncdu, it will do a quick scan of the files and folders on your system to determine folder and file sizes. This is the main objective of the tool and what I believe it is used best for.

Once the scan is complete, you can cd into a directory to save on browsing to it from root and simply run the command ncdu. I want to take a look at my Media directory and see how large a folder is on the system, so I cd into /srv on my Open Media Vault server like so.

Turn device sideways for larger view

From here you can delete entire folders or single files on your system by pressing "d" if you choose. By pressing "Shift+?" on your keyboard, it will bring up the help menu showing you other key commands you can use.

Final Notes and Thoughts

Tools like ncdu are an absolute life safer for quickly diagnosing what's eating all your storage space! It's very easy to use and requires no extra plugins or addons. It just works as intended and can be a great asset to your homelab.

💬 Anonymous comments are welcomed but manually approved

Great! Next, complete checkout for full access to Noted.
Welcome back! You've successfully signed in.
You've successfully subscribed to Noted.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.