官网地址:https://dev.yorhel.nl/ncdu
Ncdu 是一个带有 ncurses 接口的磁盘使用分析器。它旨在在您没有完整图形设置可用的远程服务器上分析磁盘占用情况。
安装
本问以 centos 系统为例
yum 方式
yum install -y ncdu
如果提示没有找到 ncdu 请安装 epel-release
yum install -y epel-release
文件方式
-
下载编译好的文件
wget -O ncdu.tar.gz https://dev.yorhel.nl/download/ncdu-1.16.tar.gz
- 解压文件
tar -zxvf ncdu.tar.gz
- 移动至
usr/bin
sudo mv ncdu* /usr/bin
使用
ncdu <options> <directory>
(默认为当前路径)
配置项:
-h,–help | This help message |
-q | Quiet mode, refresh interval 2 seconds |
-v,-V,–version | Print version |
-x | Same filesystem |
-e | Enable extended information |
-r | Read only |
-o FILE | Export scanned directory to FILE |
-f FILE | Import scanned directory from FILE |
-0,-1,-2 | UI to use when scanning (0=none,2=full |
–si | Use base 10 (SI) prefixes instead of |
–exclude PATTERN | Exclude files that match PATTERN |
-X, --exclude-from FILE | Exclude files that match any pattern |
-L, --follow-symlinks | Follow symbolic links (excluding |
–exclude-caches | Exclude directories containing |
–exclude-kernfs | Exclude Linux pseudo filesystems |
–confirm-quit | Confirm quitting ncdu |
–color SCHEME | Set color scheme (off/dark) |
执行后回出现一个扫描的界面,这个过程长短和传入的
directory
大小有关,扫描完就可以使用快捷键进行相关操作
- ? – 显示帮助界面
- up, down j, k – 上下移动光标
- right, enter, l – 打开所选目录
- left, <, h – 返回上层目录
- n – 按照文件名排序(再按一下倒序排列)
- s – 按照文件大小排序(再按一下倒序排列)
- C – 按照项目数排序(再按一下倒序排列)
- a – 切换磁盘用量显示
- d – 删除所选的文件或目录
- i – 显示所选项的更多信息
- r – 刷新/重新计算当前目录
- b – 在当前目录下打开 shell