Installing and Using ‘ncdu’ Linux Disk Manager

Installing and Using ‘ncdu’ Linux Disk Manager

Visual depiction of a Linux terminal with the process of installing the ncdu command used for disk usage analysis

Are you finding it challenging to manage disk usage in Linux? The ‘ncdu’ command, akin to a savvy accountant, can help you keep a tab on your disk usage. Installing Linux commands might seem a bit daunting, however, the ‘ncdu’ command is a powerful tool that is definitely worth learning to install and use. It’s also available on most package management systems, simplifying the installation once you understand the process.

In this guide, we will navigate the process of installing the ‘ncdu’ command on your Linux system. We will provide you with installation instructions for Debian and Ubuntu using APT package management, and CentOS and AlmaLinux using YUM package manager. We’ll also delve into advanced topics like compiling from source and installing a specific version. Finally, we will show you how to use the ‘ncdu’ command and verify that the correct version is installed.

Let’s get started with the step-by-step ncdu installation on your Linux system!

TL;DR: How Do I Install and Use the ‘ncdu’ Command in Linux?

In most Linux distributions, you can install 'ncdu' using the command, sudo apt install ncdu or sudo yum install ncdu. You can then verify the installation with the command, ncdu -v.

In Debian-based distributions like Ubuntu, you can run the following command:

sudo apt-get install ncdu

Once the installation is complete, you can start using it by typing ncdu in the terminal. Here’s an example:


This command will start scanning your current directory and display the disk usage.

This is just a basic way to install and use the ‘ncdu’ command in Linux, but there’s much more to learn about this powerful tool. Continue reading for more detailed information and advanced usage scenarios.

Getting Started with ‘ncdu’ Command in Linux

The ‘ncdu’ (NCurses Disk Usage) command is a disk utility for Unix systems, designed to find space hogs on a remote server. It provides a fast way to see what directories are using your disk space. With ‘ncdu’, you can navigate the directories and see their sizes, making it an invaluable tool for cleaning up your system or understanding where your disk space is being used.

Installing ‘ncdu’ with APT (Debian and Ubuntu)

If you are using a Debian-based distribution like Ubuntu, you can install ‘ncdu’ using the Advanced Packaging Tool (APT). Here is how you can do it:

sudo apt update
sudo apt install ncdu

The first command updates your package lists, ensuring you get the latest version of ‘ncdu’. The second command installs ‘ncdu’.

Installing ‘ncdu’ with YUM (CentOS and AlmaLinux)

For CentOS, AlmaLinux, and other Red Hat-based distributions, you can use the Yellowdog Updater, Modified (YUM). Here is the command:

sudo yum install ncdu

This command will install ‘ncdu’ on your system.

Installing ‘ncdu’ with Pacman (Arch Linux)

If you’re using Arch Linux or an Arch-based distribution like Manjaro, you can install ‘ncdu’ with the Pacman package manager. Here’s how:

sudo pacman -Sy ncdu

This command will synchronize the package databases and install ‘ncdu’.

Once ‘ncdu’ is installed, you can start using it by typing ncdu in the terminal. For example:

ncdu /home

This command will start scanning your home directory and display the disk usage.

In the next section, we will delve into more advanced usage of the ‘ncdu’ command.

Installing ‘ncdu’ from Source Code

If the ‘ncdu’ package is not available in your distribution’s package manager, or you need a different version, you can compile it from the source code. Here’s how you can do it:

tar -xzvf ncdu-1.15.1.tar.gz
cd ncdu-1.15.1
sudo make install

This set of commands will download the source code, extract it, navigate into the directory, configure the build, compile the code, and finally install ‘ncdu’.

Installing Different Versions of ‘ncdu’

From Source

To install a different version of ‘ncdu’ from source, you would replace the version number in the download URL with the version number you want. For example, to install version 1.14, you would use this command:

tar -xzvf ncdu-1.14.tar.gz
cd ncdu-1.14
sudo make install

Using Package Managers


To install a specific version of ‘ncdu’ using APT, you can use the = operator followed by the version number. Here’s how:

sudo apt-get install ncdu=1.14-1


With YUM, you can list all available versions of ‘ncdu’ with this command:

yum --showduplicates list ncdu

Then, you can install a specific version like this:

sudo yum install ncdu-1.14-1

Here are some of the key changes in recent ‘ncdu’ versions:

VersionKey Changes
1.15Added support for displaying file flags
1.14Added a new option to ignore files smaller than a certain size
1.13Improved handling of hard links

Depending on your use case, you might prefer a version with specific features or improvements.

Basic Usage and Verification

Using the Command

Once ‘ncdu’ is installed, you can use it to analyze your disk usage. For example, to analyze your entire file system, you can use this command:

ncdu /

This will start scanning your entire file system and display the disk usage.

Verifying the Installation

To verify that ‘ncdu’ is installed correctly, you can check its version with this command:

ncdu -v

This command will display the version of ‘ncdu’ that is currently installed on your system. For example, it might display something like this:

ncdu 1.15

This output indicates that version 1.15 of ‘ncdu’ is installed.

Alternative Methods for Analyzing Disk Usage in Linux

While ‘ncdu’ is a powerful tool for managing disk usage, it’s not the only one available. There are other methods and tools you can use to analyze disk usage in Linux, each with its own advantages and disadvantages. Let’s explore some of these alternatives.

Using the ‘du’ Command

The ‘du’ (Disk Usage) command is a standard tool available on most Unix-based systems, including Linux. It provides a quick overview of the disk usage in a directory. Here’s an example of how to use it:

du -sh /home

This command will display the total disk usage of your home directory. The -s option tells ‘du’ to display a summary, and the -h option makes the output human-readable, showing sizes in KB, MB, or GB as appropriate.

The output might look like this:

# Output:
1.2G    /home

This output indicates that your home directory is using 1.2 GB of disk space.

Using Graphical Tools

If you prefer a graphical interface, there are several tools you can use. One of the most popular is ‘Baobab’, also known as the Disk Usage Analyzer. It provides a graphical view of your disk usage, allowing you to see at a glance which directories are using the most space.

To install Baobab on Ubuntu, you can use this command:

sudo apt install baobab

Once installed, you can start Baobab from the command line like this:


This command will open the Baobab window, where you can select a directory to analyze.


While ‘ncdu’ is a powerful and flexible tool, the ‘du’ command is simpler and available on virtually all Unix-based systems. For a graphical view of your disk usage, Baobab is an excellent choice. Depending on your needs and preferences, you might find one of these alternatives more suitable.

Troubleshooting ‘ncdu’ Command Issues

While ‘ncdu’ is a robust tool, you may encounter some issues while using it. Here, we will discuss common problems and their solutions.

‘ncdu’: Command Not Found

If you see a message like this:

ncdu: command not found

It means that ‘ncdu’ is not installed on your system or not in your PATH. You can verify if ‘ncdu’ is installed by checking its version:

ncdu -v

If ‘ncdu’ is installed, this command will display its version. If not, you’ll see a message like ‘ncdu: command not found’. If this is the case, refer back to the installation instructions in the previous sections.

Permission Denied

If you see a message like this:

ncdu: /root: Permission denied

It means that you don’t have permission to read the directory. You can solve this problem by running ‘ncdu’ with ‘sudo’:

sudo ncdu /

This command will run ‘ncdu’ with root permissions, allowing it to read all directories.

Incorrect Disk Usage

If ‘ncdu’ shows incorrect disk usage, it might be because some files or directories are hidden. ‘ncdu’ does not show hidden files or directories by default. You can display them by running ‘ncdu’ with the ‘-x’ option:

ncdu -x /

This command will display all files and directories, including hidden ones.

Remember, ‘ncdu’ is a powerful tool, but like any tool, it may require some troubleshooting. The tips shared in this section should help you resolve common issues.

Understanding Disk Usage in Linux

Before diving deeper into the ‘ncdu’ command, it’s crucial to understand the concept of disk usage in Linux. Disk usage refers to the amount of disk space used by files and directories on your system. It’s an essential aspect of system administration, as it allows you to monitor your system’s health and optimize its performance.

Why Managing Disk Space Matters

Managing disk space is crucial for maintaining a healthy and efficient system. Over time, your system accumulates files — from system logs to user data. If not managed properly, these files can fill up your disk, leading to potential issues. These might include:

  • System Slowdown: When your disk is near capacity, your system may slow down, negatively impacting performance.

  • Application Errors: Some applications may fail to run correctly or crash when disk space is low.

  • Data Loss: In extreme cases, a full disk could lead to data loss if new data can’t be written.

Monitoring and managing disk usage can help prevent these issues, ensuring your system runs smoothly.

Disk Usage in Linux: The Basics

In Linux, disk usage is often checked using the ‘du’ command. For example, to check the disk usage of the current directory, you could use the following command:

du -sh .

This command uses the ‘-s’ option to display a summary of the total size of the current directory (‘.’) and the ‘-h’ option to make the output human-readable. The output might look like this:

# Output:
692M    .

This output indicates that the current directory uses 692 megabytes of disk space.

While ‘du’ provides a basic overview of disk usage, it’s not as user-friendly or detailed as ‘ncdu’. The ‘ncdu’ command offers a more interactive and detailed view, making it easier to identify large files or directories.

In the following sections, we’ll explore how to install and use the ‘ncdu’ command to manage disk usage in Linux effectively.

The Relevance of Disk Usage Analysis in System Administration

Disk usage analysis is not just about freeing up space on your Linux system. It’s a crucial part of system administration and performance optimization. By regularly analyzing your disk usage, you can identify potential issues before they become problems, optimize your system’s performance, and make informed decisions about resource allocation.

Exploring Related Concepts: File System Management and Disk Partitioning

Understanding disk usage in Linux is just the tip of the iceberg. To truly master Linux system administration, you need to delve into related concepts like file system management and disk partitioning.

File system management involves organizing and controlling how data is stored and retrieved on a disk. It includes tasks like creating, deleting, and moving files and directories, as well as managing permissions and ownership.

Disk partitioning, on the other hand, involves dividing a disk into separate sections, each acting as a separate disk. Partitioning allows you to manage your disk space more efficiently, isolate system and user data, and even install multiple operating systems on the same disk.

In the context of ‘ncdu’, understanding these concepts can help you better interpret the output of the command and make more effective decisions about managing your disk space.

Further Resources for Mastering Linux Disk Management

Here are some resources that can help you deepen your understanding of disk usage analysis and related concepts in Linux:

  1. The Linux Command Line: A Complete Introduction by William E. Shotts Jr. This book provides a comprehensive introduction to the Linux command line, including disk management commands.

  2. Linux Disk Management with fdisk by How-To Geek. This guide provides an in-depth look at disk partitioning in Linux using the ‘fdisk’ command.

  3. Linux File System Hierarchy by The Linux Documentation Project. This guide explains the Linux file system hierarchy, a crucial concept for understanding disk usage in Linux.

Wrapping Up: Installing the ‘ncdu’ Command for Efficient Disk Usage in Linux

In this comprehensive guide, we’ve delved into the process of installing and using the ‘ncdu’ command in Linux, a powerful tool for managing disk usage.

We began with the basics, walking you through the steps to install ‘ncdu’ using various package managers like APT, YUM, and Pacman. We then explored more advanced topics, such as installing ‘ncdu’ from source code, installing specific versions, and verifying the installation. Along the way, we provided plenty of code examples and their explanations to help you understand each step.

We also tackled common issues you might encounter when using ‘ncdu’, such as ‘command not found’ and ‘permission denied’ errors, providing you with solutions to overcome these challenges. Furthermore, we introduced alternative methods for analyzing disk usage in Linux, such as the ‘du’ command and graphical tools like Baobab. Here’s a quick comparison of these methods:

‘ncdu’Detailed, interactive view of disk usageMay require troubleshooting for some systems
‘du’Available on most Unix-based systemsLess user-friendly than ‘ncdu’
BaobabGraphical view of disk usageRequires a graphical environment

Whether you’re just starting out with ‘ncdu’ or you’re looking to level up your Linux system administration skills, we hope this guide has given you a deeper understanding of ‘ncdu’ and its capabilities.

With its balance of detail, interactivity, and ease of use, ‘ncdu’ is an invaluable tool for managing disk usage in Linux. Now, you’re well equipped to keep your Linux system clean and efficient. Happy coding!