Search Our Database
How to install and use “ncdu” on a Linux Server
Introduction
ncdu (NCurses Disk Usage) is a disk usage analyzer for Unix-like systems. It provides a fast and easy-to-use interface to view disk usage in a tree-like format, ideal for quickly finding large files or directories. Unlike traditional du commands, ncdu offers an interactive, visual interface.
Prerequisites
- Root or sudo access: You’ll need administrative privileges to install packages.
- Access to the terminal: This guide assumes you have SSH or terminal access to your Linux system.
Step-by-Step Guide
Step 1: Install ncdu
Below are the installation commands for common Linux distributions:
For Debian/Ubuntu:
sudo apt update sudo apt install ncdu
For RHEL/CentOS/AlmaLinux:
If you’re using CentOS 7 or older, you may need the EPEL repository:
sudo yum install epel-release sudo yum install ncdu
For Fedora:
sudo dnf install ncdu
For Arch Linux:
sudo pacman -S ncdu
Verify the installation with the following command:
ncdu --version
Step 2: Using ncdu to Analyze Disk Usage
To start analyzing disk usage in the current directory:
ncdu
To scan a specific directory:
ncdu /path/to/directory
Step 3: Navigating the ncdu Interface
Example Output of ncdu:
ncdu 1.14 ~ Use the arrow keys to navigate, press ? for help --- /home/user ---------------------------------------------------------------- 30.0 GiB [##########] /Documents 5.0 GiB [## ] /Pictures 1.5 GiB [# ] /Downloads 600.0 MiB [ ] /Videos 300.0 MiB [ ] /Music 90.0 MiB [ ] /Projects 45.0 MiB [ ] /Desktop e 30.0 MiB [ ] /Email_Archives 2.0 MiB [ ] /Public 500.0 KiB [ ] /scripts 160.0 KiB [ ] /config
This interface makes it easy to identify large files or directories and clean up disk space interactively.
-
- Arrow Keys: Use the up and down arrow keys to navigate through files and directories.
- Size of directories: Each directory or file is displayed with its size, and a visual bar (e.g., ###########) shows relative sizes.
- Enter: Press Enter to explore a directory.
- d: Press “d” to delete the selected file or directory.
- q: Press “q” to quit.
Step 4: Additional ncdu Options
- -x: Limit the scan to the current filesystem:
ncdu -x /
- –exclude: Exclude specific directories or files:
ncdu --exclude /proc
- -r: Generate a disk usage report:
ncdu -r /
Conclusion
By following these steps, you have successfully installed and used ncdu to analyze disk usage on your Linux server. This tool helps you efficiently manage disk space by providing a fast and interactive way to identify large files and directories.
For further assistance or issues, please contact our support team at support@ipserverone.com.