Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 15, 2026·2 min de lectura

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.

Listo para agents

Instalación con revisión previa

Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.

Needs Confirmation · 64/100Política: confirmar
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
gdu guide
Comando con revisión previa
npx -y tokrepo@latest install bcef0993-389d-11f1-9bc6-00163e2b0d79 --target codex

Primero dry-run, confirma las escrituras y luego ejecuta este comando.

TL;DR
gdu scans disk usage with parallel goroutines, shows an interactive TUI, and supports non-interactive CI output.
§01

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.

§02

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.

§03

How to use

  1. 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
  1. Launch the interactive TUI:
gdu
  1. 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
§04

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
§05

Related on TokRepo

§06

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-cross or 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 -l flag to count hard links.

Preguntas frecuentes

How does gdu compare to ncdu?+

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.

Can gdu delete files?+

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.

Does gdu work on Windows?+

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.

How do I exclude directories from the scan?+

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.

Is gdu suitable for monitoring disk usage in production?+

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.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados