NCDU - Free your disk space
CLI Tool of the month: NCDU
If you’ve ever received a warning about low disk space, you’re likely familiar with the following scenario: You clear out the usual places — your Downloads folder, cache files, and so on — only to find that you’re still low on space. You might then turn to
du commands to unearth that deeply nested subfolder containing a 106GB log file. If you're like me, you'll also find yourself Googling the correct arguments for du because they're easy to forget. Fortunately, there's a simpler solution: NCDU.
Simplified, NCDU is a terminal-based GUI for
du, where "nc" stands for ncurses. Because it runs in the terminal, it's especially useful for remote servers and similar environments.
Installing NCDU is straightforward. You can download a static binary directly from the website. NCDU is also available via the package managers of common distributions:
sudo apt-get install ncdu # Debian/Ubuntu
sudo yum install ncdu # Red Hat/Fedora
For Windows users, the Windows Subsystem for Linux (WSL) can be used to install NCDU. macOS users can install it via homebrew:
brew install ncdu
Running NCDU is simple. Open your terminal and type
ncdu, followed by the directory you wish to analyze (optional). If you omit the directory, the current working directory will be used:
NCDU will scan the directory and its subdirectories, displaying the results in a list.
Navigation is straightforward: use the arrow keys to move through the list, with the right arrow opening the current subfolder and the left arrow taking you up one level. Vim users will appreciate that they can also use
j for navigation.
You can delete files directly from NCDU by pressing
d. To recalculate a folder's size, press
That’s basically it! A simple tool, but with great benefit. I personally find it more useful to have a graphical, interactive representation in my terminal than to rely solely on a series of
In summary, NCDU is a robust, user-friendly tool that simplifies the often daunting task of disk usage analysis. If you’re aiming to free up disk space or perform NCDU has you covered. It’s a simple tool, but the benefits are immense.
I hope you found this guide useful! If you have any tips, tricks, or experiences you’d like to share about using NCDU,
df, please feel free to comment below. 💬👇
Don’t forget to subscribe for more tech insights and tutorials.