How to Show Colorized Disk Space Usage in Linux?

Linux is a popular open-source operating system that has gained immense popularity over the years due to its flexibility and stability. As we use our computers for various tasks like downloading software, creating and storing files, and performing other tasks, it is crucial to keep an eye on disk space usage. If your disk space becomes full, it can lead to various performance issues and errors for your machine. Therefore, it is essential to monitor your disk space usage regularly.

In this tutorial, we are going to explore how to show colorized disk space usage in Linux. We will discuss methods that can be used for displaying color-coded disk space usage. We'll use a command-line tool called ncdu that provides an interactive interface for the disk usage analysis.

Installing ncdu

Ncdu stands for "NCurses Disk Usage" and it provides an interactive GUI for analyzing disk usage. The tool allows us to navigate through directories and files, and view the disk usage in a clear and concise manner.

To use ncdu, we need to first install it on our Linux system. For Debian/Ubuntu-based systems, we can use the apt-get package manager to install ncdu

sudo apt-get install ncdu

For a Fedora/RHEL-based system, we can use the dnf package manager to install ncdu

sudo dnf install ncdu

For Arch Linux-based systems, we can use the pacman package manager to install ncdu

sudo pacman -S ncdu

Using ncdu to Display Disk Usage

Ncdu provides a user-friendly interface that allows us to easily navigate through directories and view their disk usage. We can use the arrow keys to move up and down the directory tree, and the Enter key to open a directory or file. Ncdu also provides the option to delete files and directories directly from the interface, which can be helpful in freeing up disk space.

When we run ncdu, it displays a color-coded list of directories and files along with their disk usage. The color coding helps us quickly identify the directories and files that are taking up the most space on our system. By default, ncdu sorts the directories and files in decreasing order of size, so we can easily see which directories and files are using the most disk space.

Color Coding Scheme

The color coding used by ncdu is as follows

  • Green Directories

  • Blue Regular files

  • Red Files that are not accessible to the current user

  • Yellow Symbolic links

Examples

Basic Usage

To use ncdu to display disk usage for the current directory, simply run

ncdu
ncdu 1.14.1 ~ Use the arrow keys to navigate, press ? for help
--- /home/user ---
    34.4 GiB [##########] /Downloads
     7.9 GiB [##        ] /Documents
     2.2 GiB [          ] /Music
   870.3 MiB [          ] /Pictures
   620.9 MiB [          ] /Videos
   513.2 MiB [          ] /VirtualBox VMs
   189.7 MiB [          ] /Snap
    76.6 MiB [          ] /bin
    72.5 MiB [          ] /lib
    41.2 MiB [          ] /opt
    34.5 MiB [          ] /boot
     9.2 MiB [          ] /sbin
     5.5 MiB [          ] /include
     3.1 MiB [          ] /src
     1.8 MiB [          ] /lib32
   192.0 KiB [          ] /share
   176.0 KiB [          ] /local

Analyzing a Specific Directory

If we want to display the disk usage of a specific directory, we can specify the directory path as an argument to the ncdu command. For example, to display the disk usage of the Downloads directory

ncdu Downloads
--- /Users/pryadav8/Downloads --------
    3.1 GiB [##########################] /tagic
    1.1 GiB [#########                 ] /tagic-admin
  845.6 MiB [#######                   ] /tagicpartner
  771.6 MiB [######                    ] /apiGateway
  404.3 MiB [###                       ] /tagicclientmarine
  331.0 MiB [##                        ] /installers
  145.4 MiB [#                         ] /apache-jmeter-5.5
  112.1 MiB [                          ]  files-WhatsApp.dmg
   93.6 MiB [                          ] /images
   81.5 MiB [                          ]  apache-jmeter-5.5.tgz
Total disk usage:   7.5 GiB  Items: 476,499

Key Features

Feature Description
Interactive Navigation Use arrow keys to browse directories
Color-coded Display Different colors for files, directories, and links
Size Sorting Automatically sorts by size (largest first)
File Deletion Press 'd' to delete files/directories
Export Results Save analysis to file for later use

Navigation Controls

  • Arrow keys Navigate up/down through files and directories

  • Enter Enter selected directory

  • Left arrow or Backspace Go back to parent directory

  • d Delete selected file/directory (with confirmation)

  • q Quit ncdu

  • ? Show help screen with all available commands

Conclusion

Ncdu is a powerful command-line tool that provides an intuitive way to analyze disk usage with colorized output. Its interactive interface makes it easy to navigate through the filesystem and identify space-consuming directories and files. The color coding and sorting features help system administrators quickly locate and manage storage issues on Linux systems.

Updated on: 2026-03-17T09:01:39+05:30

364 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements