gdu Disk Usage Analyzer

repository·master·Indexed 26 days ago

https://github.com/dundee/gdu

A fast disk usage analyzer written in Go and optimized for SSDs through parallel processing. It features an interactive TUI for navigating and deleting files, a non-interactive mode for scripting and data export, and support for persisting analysis data using SQLite or BadgerDB. Gdu allows for advanced filtering by file type and modification age, as well as the ability to ignore specific directories or patterns.

Tokens
3.8K
Snippets
10
Records
27
Agent score
90%

What's inside gdu

  1. Install gdu via COPR builds (RPM-based Linux)

    master

    COPR builds are available for Amazon Linux 2023, EPEL (7, 8, and 9), and Fedora (38 and 39). To use them, you must enable the specific COPR repository in your system configuration.

    Example configuration for Amazon Linux 2023:

    [copr:copr.fedorainfracloud.org:faramirza:gdu]
    name=Copr repo for gdu owned by faramirza
    baseurl=https://download.copr.fedorainfracloud.org/results/faramirza/gdu/amazonlinux-2023-$basearch/
    type=rpm-md
    skip_if_unavailable=True
    gpgcheck=1
    gpgkey=https://download.copr.fedorainfracloud.org/results/faramirza/gdu/pubkey.gpg
    repo_gpgcheck=0
    enabled=1
    enabled_metadata=1
    [copr:copr.fedorainfracloud.org:faramirza:gdu]
    name=Copr repo for gdu owned by faramirza
    baseurl=https://download.copr.fedorainfracloud.org/results/faramirza/gdu/amazonlinux-2023-$basearch/
    type=rpm-md
    skip_if_unavailable=True
    gpgcheck=1
    gpgkey=https://download.copr.fedorainfracloud.org/results/faramirza/gdu/pubkey.gpg
    repo_gpgcheck=0
    enabled=1
    enabled_metadata=1
  2. Save Analysis to a Database

    master

    You can persist Gdu analysis data using SQLite or BadgerDB. This allows you to skip re-scanning by reading from the existing database.

    • SQLite: Use -D or --db with a .sqlite extension.
    • BadgerDB: Use -D or --db with a .badger extension.
    • Read: Use -r or --read-from-storage to use the existing database.
  3. Run Gdu via Docker

    master

    To run Gdu in a Docker container and analyze the host's root directory, use the following command. Note that the --privileged flag is required to access the filesystem.

    docker run --rm --init --interactive --tty --privileged --volume /:/mnt/root ghcr.io/dundee/gdu /mnt/root
  4. Use Gdu in Interactive Mode

    master

    Interactive mode is the default. It allows you to navigate the filesystem and perform actions like deleting files.

    Basic Actions:

    • or k: Move cursor up
    • or j: Move cursor down
    • , Enter, or l: Go to highlighted directory
    • or h: Go to parent directory
    • d: Delete the selected file or directory
    • e: Empty the selected directory
    • n: Sort by name
    • s: Sort by size
    • c: Show number of items in directory
    • ?: Show help modal
  5. Install gdu via various package managers

    master

    You can install gdu using several different package managers depending on your operating system:

    Linux

    • Arch Linux: pacman -S gdu
    • Debian: apt install gdu
    • Ubuntu:
      add-apt-repository ppa:daniel-milde/gdu
      apt-get update
      apt-get install gdu
    • NixOS: nix-env -iA nixos.gdu
    • Snap:
      snap install gdu-disk-usage-analyzer
      snap connect gdu-disk-usage-analyzer:mount-observe :mount-observe
      snap connect gdu-disk-usage-analyzer:system-backup :system-backup
      snap alias gdu-disk-usage-analyzer.gdu gdu
    • Binenv: binenv install gdu
    • X-cmd: x env use gdu

    macOS

    • Homebrew: brew install -f gdu. Note that Homebrew installs the binary as gdu-go to avoid conflicts with coreutils.

    Windows

    • Winget: winget install gdu. You can run it as gdu_windows_amd64.exe or set an alias.
    • Scoop: scoop install gdu

    Other

    • Conda Forge: conda install gdu
    • Mise: mise use -g gdu@latest
    • Go: go install github.com/dundee/gdu/v5/cmd/gdu@latest
    go install github.com/dundee/gdu/v5/cmd/gdu@latest
  6. Configure gdu on Windows

    master

    After installing via Winget, the binary is named gdu_windows_amd64.exe. To use the command gdu, you can:

    1. Add an alias with Doskey.
    2. If using Git Bash, add alias gdu="gdu_windows_amd64.exe" to your ~/.bashrc file.

    You may need to restart your terminal for changes to take effect.

    alias gdu="gdu_windows_amd64.exe"
  7. Use Gdu in Non-Interactive Mode

    master

    Non-interactive mode is used for scripting or quick summaries. It is triggered automatically if the output is piped or if you use the -n flag.

    In this mode, Gdu uses a memory-efficient analyzer that only tracks top-level directory totals unless --top or --depth flags are provided.

    Common Non-Interactive Commands:

    • gdu -n /: Print stats only.
    • gdu -ps /some/dir: Show only total usage for a directory.
    • gdu -t 10 /: Show the top 10 largest files.
    • gdu --reverse-sort -n /: Show files sorted from smallest to largest.
    gdu -n /
    gdu -ps /some/dir
    gdu -t 10 /
  8. Save and reload analysis data to a database

    master

    Gdu can store analysis data in a database file instead of memory, allowing you to save results and reload them later without re-running the full analysis.

    Supported database engines:

    • SQLite
    • BadgerDB

    To save data, use the --db flag followed by the database path. To reload saved data without performing a new analysis, use the -r flag along with the --db flag.

  9. Enable profiling in Gdu

    master

    You can collect profiling data by using the --enable-profiling flag. This starts an embedded HTTP server at http://localhost:6060/debug/pprof/.

    To view a heap profile as an SVG image in your browser, use the go tool pprof command.

  10. Install Gdu

    master

    You can install Gdu by downloading the binary from the releases page.

    To install on Linux via curl:

    1. Download and extract the tarball.
    2. Make the binary executable.
    3. Move it to your PATH (e.g., /usr/bin/gdu).

    Alternatively, you can run Gdu using Docker to analyze your root filesystem.

    curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
    chmod +x gdu_linux_amd64
    mv gdu_linux_amd64 /usr/bin/gdu