Skip to content

ncdu: The Lazy Admin’s Disk-Space Detective

ncdu (NCurses Disk Usage) is a command-line tool that turns disk-space sleuthing into a breeze.

ncdu 是一款命令行下的磁盘分析工具,使用交互界面,查询系统中的大文件。

Installation

sudo apt install ncdu        # Debian/Ubuntu
sudo yum install ncdu        # CentOS/RHEL
brew install ncdu            # macOS (via Homebrew)

Basic usage

  1. Scan your system:

    ncdu /                  # Scan root (use sudo for system directories)
    ncdu ~/Downloads        # Target a specific folder
    

  2. Navigate:

  3. ↑/↓: Move between items.
  4. Enter: Open a directory.
  5. ←: Go back.
  6. d: Delete selected file/dir (double-check before hitting this!).
  7. ?: Toggle help menu.

  8. Quit: Press q or Ctrl+C.


Pro tips

  • Limit scan depth to save time:
    ncdu --max-depth=3 /   # Scan only 3 subdirectory levels
    
  • Exclude folders (e.g., external drives):
    ncdu --exclude /mnt /
    
  • Export/Reload results:
    ncdu -o scan_result.txt /path   # Save scan
    ncdu -f scan_result.txt         # Reopen later