Analyze disk usage in Linux like a pro with ncdu

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

Similar to bat, 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).

While 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 ncdu output.
--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).


by

Comments

One response to “Analyze disk usage in Linux like a pro with ncdu”

  1. […] Once installed, TLDR is as easy to use as it gets:Forgot how to use bat or ncdu? […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.