gdu

Disk usage analyzer with console interface written in Go

Github星跟蹤圖

go DiskUsage()

Build Status
codecov
Go Report Card
Maintainability
CodeScene Code Health

Pretty fast disk usage analyzer written in Go.

Gdu is intended primarily for SSD disks where it can fully utilize parallel processing.
However HDDs work as well, but the performance gain is not so huge.

asciicast

Installation

Head for the releases and download binary for your system.

Using curl:

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

Arch Linux:

yay -S gdu

Debian:

dpkg -i gdu_*_amd64.deb

Ubuntu

add-apt-repository ppa:daniel-milde/gdu
apt-get update
apt-get install gdu

NixOS:

nix-env -iA nixos.gdu

Homebrew:

brew install -f gdu
brew link --overwrite gdu  # if you have coreutils installed as well

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

Go:

go get -u github.com/dundee/gdu/v4/cmd/gdu

Usage

  gdu [flags] [directory_to_scan]

Flags:
  -h, --help                          help for gdu
  -i, --ignore-dirs strings           Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
  -I, --ignore-dirs-pattern strings   Absolute path patterns to ignore (separated by comma)
  -l, --log-file string               Path to a logfile (default "/dev/null")
  -m, --max-cores int                 Set max cores that GDU will use. 8 cores available (default 8)
  -c, --no-color                      Do not use colorized output
  -x, --no-cross                      Do not cross filesystem boundaries
  -H, --no-hidden                     Ignore hidden directories (beggining with dot)
  -p, --no-progress                   Do not show progress in non-interactive mode
  -n, --non-interactive               Do not run in interactive mode
  -a, --show-apparent-size            Show apparent size
  -d, --show-disks                    Show all mounted disks
  -v, --version                       Print version

Examples

gdu                                   # analyze current dir
gdu -a                                # show apparent size instead of disk usage
gdu <some_dir_to_analyze>             # analyze given dir
gdu -d                                # show all mounted disks
gdu -l ./gdu.log <some_dir>           # write errors to log file
gdu -i /sys,/proc /                   # ignore some paths
gdu -I '.*[abc]+'                     # ignore paths by regular pattern
gdu -c /                              # use only white/gray/black colors

gdu -n /                              # only print stats, do not start interactive mode
gdu -np /                             # do not show progress, useful when using its output in a script
gdu / > file                          # write stats to file, do not start interactive mode

Gdu has two modes: interactive (default) and non-interactive.

Non-interactive mode is started automtically when TTY is not detected (using go-isatty), for example if the output is being piped to a file, or it can be started explicitly by using a flag.

Hard links are counted only once.

File flags

Files and directories may be prefixed by a one-character
flag with following meaning:

  • ! An error occurred while reading this directory.

  • . An error occurred while reading a subdirectory, size may be not correct.

  • @ File is symlink or socket.

  • H Same file was already counted (hard link).

  • e Directory is empty.

Running tests

make test

Benchmarks

Benchmarks performed on 50G directory (100k directories, 400k files) on 500 GB SSD using hyperfine.
See benchmark target in Makefile for more info.

Cold cache

Filesystem cache was cleared using sync; echo 3, sudo tee /proc/sys/vm/drop_caches., Command, Mean [s], Min [s], Max [s], Relative, :---, ---:, ---:, ---:, ---:, gdu -npc ~, 3.714 ± 0.036, 3.685, 3.809, 1.00, dua ~, 4.703 ± 0.011, 4.691, 4.721, 1.27 ± 0.01, duc index ~, 20.776 ± 0.093, 20.591, 20.924, 5.59 ± 0.06, ncdu -0 -o /dev/null ~, 20.933 ± 0.113, 20.757, 21.073, 5.64 ± 0.06, diskus ~, 3.747 ± 0.027, 3.707, 3.779, 1.01 ± 0.01, du -hs ~, 20.096 ± 0.128, 19.916, 20.313, 5.41 ± 0.06, dust -d0 ~, 16.281 ± 0.118, 16.148, 16.490, 4.38 ± 0.05, ### Warm cache, Command, Mean [ms], Min [ms], Max [ms], Relative, :---, ---:, ---:, ---:, ---:, gdu -npc ~, 643.5 ± 11.3, 623.8, 659.9, 1.99 ± 0.12, dua ~, 389.7 ± 13.0, 374.2, 410.4, 1.20 ± 0.08, duc index ~, 1241.1 ± 19.6, 1205.4, 1274.9, 3.84 ± 0.23, ncdu -0 -o /dev/null ~, 1846.7 ± 11.9, 1823.0, 1859.9, 5.71 ± 0.33, diskus ~, 323.4 ± 18.8, 302.1, 362.2, 1.00, du -hs ~, 1027.7 ± 9.7, 1009.0, 1037.5, 3.18 ± 0.19, dust -d0 ~, 8864.4 ± 35.9, 8798.8, 8906.6, 27.41 ± 1.60, ## Alternatives

  • ncdu - NCurses based tool written in pure C
  • godu - Analyzer with carousel like user interface
  • dua - Tool written in Rust with interface similar to gdu (and ncdu)
  • diskus - Very simple but very fast tool written in Rust
  • duc - Collection of tools with many possibilities for inspecting and visualising disk usage
  • dust - Tool written in Rust showing tree like structures of disk usage

主要指標

概覽
名稱與所有者dundee/gdu
主編程語言Go
編程語言Go (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2018-02-24 15:04:23
推送於2025-07-09 08:52:37
最后一次提交2025-07-09 14:22:37
發布數89
最新版本名稱v5.31.0 (發布於 2025-06-06 11:27:20)
第一版名稱v1.0.0 (發布於 )
用户参与
星數4.7k
關注者數28
派生數167
提交數732
已啟用問題?
問題數206
打開的問題數42
拉請求數132
打開的拉請求數11
關閉的拉請求數42
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?