When Linux servers run low on disk space, traditional utilities like df -h and du -sh * provide fragmented, hard-to-read text output that requires endless manual piping to sort and head. Two modern terminal utilities streamline filesystem auditing: duf (Disk Usage/Free Utility), which displays color-coded, structured tables of mounted filesystems and inode capacities, and ncdu (NCurses Disk Usage), an interactive, fast disk usage analyzer that lets administrators navigate directories and purge obsolete log files directly from the terminal.
Installing ncdu and duf on Linux
Both utilities are available across official repositories for major Linux distributions:
# On Ubuntu and Debian systems
sudo apt update
sudo apt install ncdu duf -y
# On RHEL, CentOS, and Fedora systems
sudo dnf install epel-release -y
sudo dnf install ncdu duf -y
| Utility | Primary Capability | Key Benefit |
|---|---|---|
| duf | Volume and mount-point overview. | Colorized progress bars, inode metrics, and automatic drive type grouping. |
| ncdu | Interactive directory tree analysis. | Instant file size sorting and in-place deletion without exiting. |
Auditing Mounted Volumes and Inodes with duf
Running duf without flags outputs a structured table categorizing local devices, special filesystems, and network mounts:
duf
To restrict the output exclusively to physical storage devices while filtering out virtual filesystems (like tmpfs or squashfs):
duf --only local
If an application reports “No space left on device” even though free disk capacity exists, the filesystem has likely exhausted its inode allocation. Inspect inode consumption using the --inodes switch:
duf --inodes
Navigating and Cleaning Disk Trees with ncdu
To inspect large directory hierarchies (such as /var/log or /home), launch ncdu on the target path:
sudo ncdu /var
ncdu scans the directory tree and renders an interactive interface:
- Use the Up/Down Arrow keys to select directories sorted by size.
- Press Enter to descend into the highlighted folder.
- Press Left Arrow to navigate back to the parent folder.
- Press d to delete the selected file or directory immediately with confirmation.
- Press i to view detailed file metadata (MIME type, exact byte size, hard links).
- Press q to quit.
Preventing File System Crossings and Exporting Reports
On production servers with NFS shares, Docker volumes, or mounted backup disks, running a recursive disk audit can accidentally crawl external storage arrays. Use the -x flag to restrict analysis strictly to the root filesystem:
sudo ncdu -x /
For remote headless servers, scan disk usage in the background and export the data to an export file for offline analysis:
# Run scan in background and save to file
sudo ncdu -1xo /tmp/disk_audit.json /
# Inspect exported report later on any workstation
ncdu -f /tmp/disk_audit.json
Pairing duf for high-level capacity checks with ncdu for targeted directory cleanup empowers Linux engineers to reclaim disk space swiftly and safely.