命令一共有两个:
du
该命令不用安装,为系统自带,常用的命令为:
du --max-depth=1 -h
gdu
重点说一下这个,很直观。首先是安装:
Using curl:
1 2 3 |
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz chmod +x gdu_linux_amd64 sudo mv gdu_linux_amd64 /usr/bin/gdu |
wget:
1 2 3 4 |
wget https://gitee.com/public_sharing/tools_link/raw/master/gdu.zip unzip gdu.zip chmod +x gdu sudo mv gdu /usr/bin/gdu |
1 2 |
yay -S gdu |
1 2 |
dpkg -i gdu_*_amd64.deb |
1 2 3 4 |
sudo add-apt-repository ppa:daniel-milde/gdu sudo apt-get update sudo apt-get install gdu |
1 2 |
nix-env -iA nixos.gdu |
1 2 3 |
brew install -f gdu brew link --overwrite gdu # if you have coreutils installed as well |
Snap:
1 2 3 4 5 |
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 |
1 2 |
binenv install gdu |
Go:
1 |
go get -u github.com/dundee/gdu/v5/cmd/gdu |
用法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Read config from file (default is $HOME/.gdu.yaml) -g, --const-gc Enable memory garbage collection during analysis with constant level set by GOGC --enable-profiling Enable collection of profiling data and provide it on http://localhost:6060/debug/pprof/ -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) -X, --ignore-from string Read absolute path patterns to ignore from file -f, --input-file string Import analysis from JSON file -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 (beginning with dot) --no-mouse Do not use mouse --no-prefix Show sizes as raw numbers without any prefixes (SI or binary) in non-interactive mode -p, --no-progress Do not show progress in non-interactive mode -n, --non-interactive Do not run in interactive mode -o, --output-file string Export all info into file as JSON -a, --show-apparent-size Show apparent size -d, --show-disks Show all mounted disks -B, --show-relative-size Show relative size --si Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB) -s, --summarize Show only a total in non-interactive mode -v, --version Print version --write-config Write current configuration to file (default is $HOME/.gdu.yaml) |
例子:
1 2 3 4 5 6 7 8 9 10 11 12 |
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 -o /Users/mcj/Downloads/result.json
加载扫描结果:
gdu -f /Users/mcj/Downloads/result.json
本文最后更新于2022年12月8日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!