NCDU: The ncurses-based disk user that any Linux administrator should know about

What is NCDU?

NCDU (NCurses Disk Usage) is a command line tool that shows the use of disk space using a ncurses-based interface. Unlike the classic du, NCDU offers an interactive view that allows you to explore directories, see real-time sizes and remove files or folders directly from the screen. Its light design and speed make it an indispensable ally for system administrators and advanced users who need to quickly identify what is consuming space in their Linux systems.

NCDU installation

In most Linux distributions, NCDU is in official repositories. In Debian or Ubuntu runs sudo apt update and then sudo apt install ncdu. In Fedora use sudo dnf install ncdu. In Arch Linux the command is sudo pacman -S ncdu. To compile from source code, download the tarball, unbuy it, run. / configure, make and sudo make install. After installation, invoke the program simply by writing ncdu in the terminal.

Basic use of NCDU

When launching ncdu without arguments, the program analyzes the current directory and shows a hierarchical list of subdirectories sorted by size. Each line indicates the name of the directory, its total size and the percentage of the total scanned. Sail with the arrows up and down to select an input and press Enter to enter. To return to the top level, use the left arrow or the h key. The lower bar shows the number of files and the free space available.

Navigation keys and actions

NCDU has useful shortcuts: use arrows or j / k to move, l to open a directory and h to raise a level. The d key removes the selected item after requesting confirmation, while c shows the content in detail mode. Click to alternate between apparent and real size. Finally, q leaves the program and returns to the shell.

Visual representation of disk use

A prominent feature of NCDU is its graphic progress bar next to each input. This bar, made with Unicode characters, intuitively shows the proportion of space occupied by each subdirectory to the father. The colors vary according to the terminal, but generally the warm tones indicate higher consumption and the cold ones indicate lower use. This display allows the rapid identification of the «Bottle necks» storage without reading exact numbers.

Advanced options and customization

NCDU accepts several parameters. For example,ncdu -rdoes a recursive tour without crossing assembly points. The optionncdu -xhas the same effect and is usually active by default. To exclude patterns, usencdu --exclude patternAs many times as you need. Withncdu -o archivoYou save the scanning in a file and then load it withncdu -f archivo, useful to compare snapshots at different times.

Comparison with du and other tools

The traditional du command provides similar but static information without interactivity. While du-sh * shows the size of each entry in the current directory, requires running multiple commands to deepen into subdirectories. NCDU, on the other hand, combines du speed with a file browser type navigation, which significantly reduces the time needed to locate large files. Other graphic tools such as Baobab or Filelight also provide visualizations, but they depend on a desktop environment and consume more resources, which NCDU avoids when operating exclusively in the terminal.

Practical examples of use

Imagine that you want to discover which of your projects occupies more space in your folder~/proyectos. Runncdu ~/proyectosand, after the analysis, navigate to the subdirectory with the longest bar; there you can see which files are the most heavy and decide whether to check, file or delete them. Another common case is to review the use of/var/log: when runningncdu /var/logYou can quickly identify the loops that have grown out of control and apply rotation or erased according to your retention policies.

Tips and tricks to make the most of it

Use the key?within NCDU to open the quick help and remember all shortcuts available. If you work with remote servers, combine NCDU withsshrunningssh usuario@host ncdu /rutato analyze the disk without transferring unnecessary data. To automate reports, program a cron task to runncdu -o /tmp/scan.ncdueach night and then send the file by email usingmailor any other means of notification. Finally, remember that NCDU respects the system's permissions; if you need to see directory sizes that you don't have access to, run the command withsudo.

Conclusion

NCDU has been consolidated as one of the most effective tools to analyze disk use in Linux environments thanks to its combination of speed, interactivity and low resource consumption. Whether you are a system manager who needs to release space on a production server or a home user who wants to order your download folder, NCDU provides you with the necessary information clearly and quickly. Install today, explore your shortcuts and find out how much you can simplify your storage management.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish