查看磁盘使用情况:df -h
[root@iZwz9gs2zseivevv1k5vnkZ /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 126G 111G 8.9G 93% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 2.7M 7.8G 1% /dev/shm
tmpfs 7.8G 310M 7.5G 4% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/dm-1 10G 202M 9.8G 2%
查找大文件
搜索当前目录下,超过800M大小的文件
find . -type f -size +800M
需要显示更多文件信息
find . -type f -size +800M -print0 | xargs -0 ls
显示文件具体大小
find . -type f -size +800M -print0 | xargs -0 du
[root@iZwz9gs2zseivevv1k5vnkZ /]# find . -type f -size +800M -print0 | xargs -0 du -h
1.1G ./www/swap
0 ./proc/kcore
821M ./usr/local/src/dubbo/nohup.out
6.6G ./root/nacos/bin/logs/access_log.2019-12-04.log
7.2G ./root/nacos/bin/logs/access_log.2019-11-28.log
7.0G ./root/nacos/bin/logs/access_log.2019-12-03.log
7.2G ./root/nacos/bin/logs/access_log.2019-12-02.log
7.3G ./root/nacos/bin/logs/access_log.2019-11-30.log
6.1G ./root/nacos/bin/logs/access_log.2019-12-05.log
7.4G ./root/nacos/bin/logs/access_log.2019-12-01.log
7.3G ./root/nacos/bin/logs/access_log.2019-11-29.log
1.4G ./var/cache/yum/x86_64/7/gitlab-ce/gen/filelists_db.sqlite
9.5M ./var/lib/docker/devicemapper/devicemapper/metadata
5.5G ./var/lib/docker/devicemapper/devicemapper/data
按照文件大小进行排序
find . -type f -size +800M -print0 | xargs -0 du -h| sort -nr
查找大文件夹
du -h --max-depth=1
如果想知道某一个目录下有哪些大文件夹,并对搜索出来的结果进行排序
du -h --max-depth=2 | sort -n
du -hm --max-depth=2 | sort -n
如果搜索出来的结果过多,比如只想查出来前20大的文件夹
du -hm --max-depth=2 | sort -nr | head -12
我还用了一下的命令 查看当前目录下的文件夹大小
du -sh *
du -s /home或du -sh /home ls -lht 或者直接 ll
[root@iZwz9gs2zseivevv1k5vnkZ /]# cd /root/nacos/bin/logs
[root@iZwz9gs2zseivevv1k5vnkZ logs]# du -sh *
7.2G access_log.2019-11-28.log
7.3G access_log.2019-11-29.log
7.3G access_log.2019-11-30.log
7.4G access_log.2019-12-01.log
7.2G access_log.2019-12-02.log
7.0G access_log.2019-12-03.log
6.6G access_log.2019-12-04.log
6.1G access_log.2019-12-05.log
业务需求变更永无休止,技术前进就永无止境!