现在使用 ncdu 的话,只需要执行一次就可以查询目录大小并排序,且删除文件也很方便,不会出错。

基本用法

安装:

# ubuntu
sudo apt install ncdu
# centos
sudo yum install ncdu
# macOS
brew install ncdu

使用

# 统计当前所在目录及子目录的文件占用情况
ncdu

# 统计指定的 /data 目录
ncdu /data

# 将 /data 目录的情况输出到 ~/ncdu.txt
ncdu /data -o ~/ncdu.txt

# 加载本地根据,而不是进行实时统计
ncdu -f ~/ncdu.txt 

References

最后修改:2025 年 09 月 07 日
如果觉得我的文章对你有用,请随意赞赏