Managing disk space on a Linux system is crucial for maintaining optimal performance and ensuring efficient resource allocation. One of the most effective tools for this task is ncdu, a disk usage analyzer that provides a detailed overview of where your disk space is being used. In this blog post, we’ll explore how to install ncdu and leverage its features to manage disk space effectively.

How to install NCDU Command

Installation Steps:

Before diving into usage, let’s start with the installation process. ncdu is available in the package repositories of most Linux distributions, making it easy to install with a few simple commands. Here’s how you can install it on popular distributions:

Debian/Ubuntu:

sudo apt update
sudo apt install ncdu
Red Hat/CentOS:
sudo yum install epel-release  # if EPEL repository is not enabled
sudo yum install ncdu
Fedora:
sudo dnf install ncdu
Arch Linux:
sudo pacman -S ncdu

Once installed, you can verify the installation by running:

ncdu --version

Using NCDU to Analyze Disk Usage

Now that ncdu is installed, let’s explore how to use it to analyze disk space usage:

  1. Launching NCDU:Simply open a terminal and type ncdu. It will start scanning the current directory and display disk usage statistics in a user-friendly interface.
  2. Navigating the Interface:
    • Navigation: Use the arrow keys to navigate through directories.
    • Sorting: Press s to change sorting methods (by size, file count, etc.).
    • Deleting Files: If needed, you can delete files directly from ncdu by selecting them and pressing d.
    • Information: Press i for detailed information about the selected directory or file.
  3. Scanning Specific Directories:To scan a specific directory, specify the path after the ncdu command:

    ncdu /path/to/directory
  4. Saving Reports:
    ncdu -o /path/to/save/report.txt
  5. Command to get tree view attached below

    ncdu -rx /

    Wait for scanning gets complete. It will take 5 to 10 mins depending upon disk and data size.

Conclusion

ncdu simplifies the task of monitoring disk space usage on Linux systems, offering both a comprehensive overview and detailed insights into where storage is being utilized. Whether you’re a system administrator managing server resources or a desktop user keeping tabs on personal storage, ncdu proves to be an invaluable tool. Its intuitive interface and powerful features make it a must-have utility in your Linux toolkit.

Next time you find yourself wondering where all your disk space has gone, remember to turn to ncdu for a clear and detailed answer!

Happy disk space managing!