gdu — Pretty Fast Disk Usage Analyzer Written in Go
gdu is a parallel disk usage analyzer in Go inspired by ncdu, optimized for SSDs, with an interactive TUI, non-interactive mode for CI, and static-binary portability.
What it is
gdu is a disk usage analyzer written in Go, inspired by ncdu. It scans filesystems using a pool of goroutines for parallel I/O, then presents results in an interactive terminal UI where you can drill into directories, sort by size, and delete files directly.
gdu is for system administrators, DevOps engineers, and developers who need to find what is consuming disk space. It works on servers (via SSH) and local machines, with a static binary that requires no dependencies.
How it saves time or tokens
Traditional du -sh requires multiple runs to drill into directories. ncdu scans sequentially, which is slow on SSDs that can handle parallel reads. gdu's goroutine-based scanning takes advantage of SSD parallelism, completing scans faster on modern storage.
The non-interactive mode (gdu -n) outputs results as plain text, suitable for CI pipelines or scripts that monitor disk usage. Combined with JSON output (--output-file report.json), you can feed results into monitoring dashboards.
How to use
- Install gdu:
# macOS
brew install -q gdu
# Linux (static binary)
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
sudo mv gdu_linux_amd64 /usr/local/bin/gdu
- Launch the interactive TUI:
gdu
- Scan a specific directory with options:
# Non-interactive, top 10 largest dirs
gdu -n /var
# Ignore paths and export JSON
gdu -i /var/log,/tmp --output-file report.json
# Show apparent size instead of disk usage
gdu -a /home
Example
Using gdu in a CI pipeline to check disk usage before deployment:
#!/bin/bash
# Check if /var/lib/docker exceeds 50GB
SIZE=$(gdu -n -p /var/lib/docker 2>/dev/null | head -1 | awk '{print $1}')
if [ "$SIZE" -gt 53687091200 ]; then
echo 'Docker storage exceeds 50GB, running cleanup'
docker system prune -af
fi
Or parse JSON output for monitoring:
gdu -n --output-file /tmp/disk-report.json /
jq '.[] | select(.size > 1073741824) | {name: .name, size_gb: (.size / 1073741824)}' /tmp/disk-report.json
Related on TokRepo
- DevOps AI tools -- infrastructure monitoring and management
- Automation tools -- scripted automation for server maintenance
Common pitfalls
- gdu's parallel scanning is optimized for SSDs. On spinning disks (HDD), parallel reads cause seek thrashing and can be slower than sequential scanning. Use
gdu --no-crossor reduce parallelism for HDDs. - The interactive TUI requires a terminal. When running over SSH with limited terminal capabilities, ensure your TERM variable is set correctly (e.g.,
xterm-256color). - gdu counts hard links separately by default. If your filesystem has many hard links (e.g., Nix store), apparent sizes may differ from actual disk usage. Use the
-lflag to count hard links.
Frequently Asked Questions
gdu and ncdu serve the same purpose, but gdu is written in Go with parallel scanning that is faster on SSDs. ncdu is written in C and scans sequentially. gdu also adds JSON output and a non-interactive mode that ncdu lacks in its stable releases.
Yes. In the interactive TUI, press 'd' to delete the selected file or directory. gdu asks for confirmation before deleting. This is useful for cleaning up large log files or cache directories directly from the analyzer.
gdu supports Windows with a static binary. The interactive TUI works in Windows Terminal and PowerShell. Some filesystem-specific features (like hard link counting) behave differently on NTFS compared to ext4 or APFS.
Use the -i flag followed by comma-separated paths: gdu -i /proc,/sys,/dev. You can also create a config file at ~/.gdu.yaml with permanent exclusion patterns.
gdu's non-interactive mode with JSON output makes it suitable for scripted monitoring. Run it on a schedule, parse the output, and alert when directories exceed thresholds. For continuous monitoring, pair it with a time-series database and alerting system.
Citations (3)
- gdu GitHub— gdu parallel disk usage analyzer in Go
- gdu README— Goroutine-based parallel filesystem scanning
- ncdu Official Site— ncdu disk usage analyzer comparison
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.