查看目录下文件用ls,如下
[root@localhost blogs]# ls
file tmpdir tmpdir_bak
查看目录全部文件大小用du -h
[root@localhost blogs]# du -h
0 ./file
8.0K ./tmpdir
4.0K ./tmpdir_bak/tmpdir
8.0K ./tmpdir_bak
16K .
有时候目录文件很大,路径很深,限制查询
du -h --max-depth=1
[root@localhost blogs]# du -h --max-depth=1
0 ./file
8.0K ./tmpdir
8.0K ./tmpdir_bak
16K .
如果你想看到所有目录及文件大小,用du -ah,和du -h两者是有不同的。
[root@localhost pycharmprojects]# du -h
0 ./data/train/BaseballPitch
0 ./data/train
4.0K ./data/.ipynb_checkpoints
8.0K ./data
8.0K .
[root@localhost pycharmprojects]# du -ah
0 ./data/train/BaseballPitch
0 ./data/train
4.0K ./data/Untitled.ipynb
4.0K ./data/.ipynb_checkpoints/Untitled-checkpoint.ipynb
4.0K ./data/.ipynb_checkpoints
8.0K ./data
8.0K .