Visualize Disk Usage as Tree Map in Ubuntu Terminal
Managing storage space is a critical task for any Ubuntu user. When the hard drive fills up, identifying large files quickly becomes necessary. This article provides a direct answer to the common question regarding which command-line utility offers a visual representation of disk consumption. You will learn the name of the tool, how to install it, and how to use it effectively to analyze your file system structure.
The utility that helps visualize disk usage as a tree map in the terminal is ncdu. Standing for NCurses Disk Usage, this tool scans your directory structure and presents the data in an interactive, visual format. Unlike the standard du command, which outputs plain text, ncdu allows you to navigate through folders using keyboard keys and see exactly which directories consume the most space.
To install ncdu on Ubuntu, open your terminal and run the following command. You will need sudo privileges to add the software to your system.
sudo apt update && sudo apt install ncdu
Once installed, you can launch the utility by typing ncdu followed by the path you wish to analyze. To scan the entire root filesystem, use the command below.
sudo ncdu /
The interface displays a bar chart representing file sizes relative to each other. You can use the arrow keys to move up and down the directory tree. Pressing Enter allows you to dive into specific folders, while pressing Delete allows you to remove files directly from the interface if necessary. This visual approach makes finding space-hogging files significantly faster than reading raw text output.