深入解析Linux 常用命令--du
2017-12-20 20:18
441 查看
深入解析Linux常用命令–du
深入解析Linux常用命令du概述
不带参数
显示所有文件及文件夹大小
显示容量大小单位
以人类可读方式
不显示0字节大小文件
显示最大深度
1.概述
du常用于查看占用空间大小。2.不带参数
默认情况下,du只显示文件夹大小。[root@smart Desktop]# ls -p aa cd.txt.bak2 ls.test test.md wireshark.desktop alias.txt du.txt ls.txt test.md~ cat.txt k.txt ls.txt.bak test.txt cd.txt linux/ test.log test.txt2 cd.txt.bak ls (copy).test~ test.log.bak test.txt3 [root@smart Desktop]# du 1340 ./linux/txt 4 ./linux/h/abcde 8 ./linux/h 4 ./linux/B/A 8 ./linux/B 4 ./linux/.dir 4 ./linux/ss 8 ./linux/test/B 16 ./linux/test 8 ./linux/d 1412 ./linux 1848 . [root@smart Desktop]#
3.显示所有文件及文件夹大小
du -a 可以显示所有的文件及文件夹大小[root@smart Desktop]# du -a 84 ./alias.txt 8 ./ls.txt 8 ./test.log.bak 8 ./ls.txt.bak 84 ./cd.txt 8 ./du.txt 4 ./test.txt2 4 ./test.txt 0 ./linux/c 4 ./linux/txt/uzip.txt 4 ./linux/txt/su.txt 4 ./linux/test/B/A 8 ./linux/test/B ... 0 ./linux/d/b.c 8 ./test.log 4 ./ls (copy).test~ 1848 . [root@smart Desktop]# [root@smart linux]# cp b.txt k.txt [root@smart linux]# cp b.txt k.txt cp: overwrite `k.txt'? y [root@smart linux]# cp -f b.txt k.txt cp: overwrite `k.txt'? y [root@smart linux]# \cp -f b.txt k.txt [root@smart linux]# alias cp='cp' [root@smart linux]# cp -r b.txt k.txt
4.显示容量大小单位
du -m/-b[root@smart linux]# du -m 2 ./txt 1 ./h/abcde 1 ./h 1 ./A 1 ./B/A 1 ./B 1 ./.dir 1 ./ss 1 ./abcde 1 ./test/A 1 ./test/B/A 1 ./test/B 1 ./test 1 ./d 2 . [root@smart linux]# du -b 1220718 ./txt 4096 ./h/abcde 8192 ./h 4096 ./A 4096 ./B/A 8192 ./B 4096 ./.dir 4096 ./ss 4096 ./abcde 4096 ./test/A 4096 ./test/B/A 8192 ./test/B 16384 ./test 4126 ./d 1278108 .
此处要注意,默认情况下,Linux系统一般都会alias cp为交互模式,可以查看~/.bashrc。
5.以人类可读方式
du -h[root@smart linux]# du -h 1.4M ./txt 4.0K ./h/abcde 8.0K ./h 4.0K ./A 4.0K ./B/A 8.0K ./B 4.0K ./.dir 4.0K ./ss 4.0K ./abcde 4.0K ./test/A 4.0K ./test/B/A 8.0K ./test/B 16K ./test 8.0K ./d 1.4M .
6.不显示0字节大小文件
du -0[root@smart linux]# du -0 1340 ./txt4 ./h/abcde8 ./h4 ./A4 ./B/A8 ./B4 ./.dir4 ./ss4 ./abcde4 ./test/A4 ./test/B/A8 ./test/B16 ./test8 ./d1412 .[root@smart linux]#
7.显示最大深度
–max-depth=N,显示几级文件夹的深度[root@smart linux]# du --max-depth=1 1340 ./txt 8 ./h 4 ./A 8 ./B 4 ./.dir 4 ./ss 4 ./abcde 16 ./test 8 ./d 1412 . [root@smart linux]# du --max-depth=2 1340 ./txt 4 ./h/abcde 8 ./h 4 ./A 4 ./B/A 8 ./B 4 ./.dir 4 ./ss 4 ./abcde 4 ./test/A 8 ./test/B 16 ./test 8 ./d 1412 . [root@smart linux]# du --max-depth=3 1340 ./txt 4 ./h/abcde 8 ./h 4 ./A 4 ./B/A 8 ./B 4 ./.dir 4 ./ss 4 ./abcde 4 ./test/A 4 ./test/B/A 8 ./test/B 16 ./test 8 ./d 1412 . [root@smart linux]#
Enjoy!
2017/12/24
相关文章推荐
- 深入解析Linux 常用命令--cut
- 深入解析Linux 常用命令--arping
- 深入解析Linux 常用命令--ls
- 深入解析Linux 常用命令--ping
- 深入解析Linux 常用命令--cat
- 深入解析Linux 常用命令--cp
- 深入解析Linux 常用命令--cd
- 深入解析Linux 常用命令--ip
- 深入解析Linux 常用命令--df
- 深入解析Linux 常用命令--top
- 深入解析Linux 常用命令--mv
- 深入解析Linux 常用命令--rm
- 深入解析Linux 常用命令--alias
- 深入解析Linux 常用命令--ps
- 深入解析Linux 常用命令--route
- 深入解析Linux 常用命令--lsof
- Linux 常用命令——df, du, ln
- 企业Linux系统管理员常用命令大全实例解析(1)
- Linux 常用命令解析和Bash Shell使用示例脚本演示
- Linux常用命令之系统管理命令top free df du