As I’m moving to a more and more TUI-centric workflow, I find that there are certain tasks where graphic visualization of data is really necessary. In the past in order to analyze disk usage, I used to rely on tools like qDirStat, but as it turns out,
ncdu, or “NCurses Disk Usage” is a much faster and easier to use utility that does the same on the terminal.
Ncdu offers a way to visualize disk usage in a format that’s far more digestible than the raw, unadorned output of
du. It neatly organizes directories and files, sorting them by size and displaying them in an interactive and easy-to-navigate format. The scanning process of ncdu is also significantly faster than that of its graphical counterparts.
ncdu: Working intuitively and with sane defaults
ncdu is built to function optimally without much tweaking. Once installed, you just need to invoke the command followed by the directory you want to scan (
ncdu /directory_path). If no directory is specified,
ncdu assumes the current directory. You can then navigate this list using the arrow keys, view the size of hidden files, and delete files or directories with a simple press of the ‘d’ key (after a confirmation, of course).
ncdu works well out of the box, it’s not a one-size-fits-all tool. It provides a set of options that let you customize its behavior according to your preferences:
--si: By default,
ncdu uses base 2 prefixes (KiB, MiB, GiB) for sizes. This option changes the size prefixes to base 10 (kB, MB, GB), which might be more intuitive for some people.
--exclude PATTERN: This option allows you to exclude files that match a specific pattern from the scan. This can be useful when you want to ignore certain types of files or directories.
-r: Read-only mode. Use this when you want to prevent accidental deletions while navigating the
--color SCHEME: This option allows you to set the color scheme of the
ncdu interface. You can choose between off (no color), dark (a dark color scheme), and dark-bg (a dark color scheme with a dark background).