df相关命令
作用:检查文件系统的磁盘空间使用情况,针对一整个文件系统的,可以理解为检查某个挂载卷的整体情况
df命令
[root@ypcvm /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 4679876 0 4679876 0% /dev
tmpfs 4691888 0 4691888 0% /dev/shm
tmpfs 4691888 11996 4679892 1% /run
tmpfs 4691888 0 4691888 0% /sys/fs/cgroup
/dev/mapper/centos-root 18552832 11312548 7240284 61% /
/dev/sda1 303780 124900 178880 42% /boot
tmpfs 938380 0 938380 0% /run/user/0
Filesystem:识别的每个文件系统
1k-block:磁盘空间大小
Use%:使用率
Mounted on:挂载点
空间大小的单位都默认为KB
df -h命令:以可读的格式显示磁盘空间使用情况,如显示为 KB、MB 或者 GB
[root@ypcvm /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.5G 0 4.5G 0% /dev
tmpfs 4.5G 0 4.5G 0% /dev/shm
tmpfs 4.5G 12M 4.5G 1% /run
tmpfs 4.5G 0 4.5G 0% /sys/fs/cgroup
/dev/mapper/centos-root 18G 11G 7.0G 61% /
/dev/sda1 297M 122M 175M 42% /boot
tmpfs 917M 0 917M 0% /run/user/0
Size:容量
df -T命令:多了文件类型列
[root@ypcvm /]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
devtmpfs devtmpfs 4679876 0 4679876 0% /dev
tmpfs tmpfs 4691888 0 4691888 0% /dev/shm
tmpfs tmpfs 4691888 11996 4679892 1% /run
tmpfs tmpfs 4691888 0 4691888 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 18552832 11312576 7240256 61% /
/dev/sda1 xfs 303780 124900 178880 42% /boot
tmpfs tmpfs 938380 0 938380 0% /run/user/0
Type: 文件类型
df -t 文件类型: 筛选指定的文件类型
[root@ypcvm /]# df -t xfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 18552832 11312556 7240276 61% /
/dev/sda1 303780 124900 178880 42% /boot
筛选xfs文件类型的文件系统
du命令
作用:查看文件所占磁盘空间的大小,可以查看某个目录的大小,也可以查看某个具体文件的大小
语法:
du [选项] [文件或目录]
du命令:默认列出当前目录所有文件的各自所占的空间
[root@ypcvm ~]# du
4 ./.cache/abrt
4 ./.cache
0 ./.config/abrt
0 ./.config
0 ./.pki/nssdb
0 ./.pki
0 ./.docker/buildx/instances
0 ./.docker/buildx/defaults
4 ./.docker/buildx/activity
8 ./.docker/buildx
8 ./.docker
196544 ./mongodb-linux-x86_64-rhel70-4.4.9/bin
196684 ./mongodb-linux-x86_64-rhel70-4.4.9
48 ./nginx/core/nginx-1.24.0/auto/cc
4 ./nginx/core/nginx-1.24.0/auto/lib/geoip
4 ./nginx/core/nginx-1.24.0/auto/lib/google-perftools
8 ./nginx/core/nginx-1.24.0/auto/lib/libatomic
4 ./nginx/core/nginx-1.24.0/auto/lib/libgd
4 ./nginx/core/nginx-1.24.0/auto/lib/libxslt
20 ./nginx/core/nginx-1.24.0/auto/lib/openssl
28 ./nginx/core/nginx-1.24.0/auto/lib/pcre
8 ./nginx/core/nginx-1.24.0/auto/lib/perl
20 ./nginx/core/nginx-1.24.0/auto/lib/zlib
108 ./nginx/core/nginx-1.24.0/auto/lib
28 ./nginx/core/nginx-1.24.0/auto/os
16 ./nginx/core/nginx-1.24.0/auto/types
392 ./nginx/core/nginx-1.24.0/auto
40 ./nginx/core/nginx-1.24.0/conf
20 ./nginx/core/nginx-1.24.0/contrib/unicode2nginx
4 ./nginx/core/nginx-1.24.0/contrib/vim/ftdetect
4 ./nginx/core/nginx-1.24.0/contrib/vim/ftplugin
4 ./nginx/core/nginx-1.24.0/contrib/vim/indent
116 ./nginx/core/nginx-1.24.0/contrib/vim/syntax
128 ./nginx/core/nginx-1.24.0/contrib/vim
156 ./nginx/core/nginx-1.24.0/contrib
912 ./nginx/core/nginx-1.24.0/src/core
152 ./nginx/core/nginx-1.24.0/src/event/modules
552 ./nginx/core/nginx-1.24.0/src/event
72 ./nginx/core/nginx-1.24.0/src/http/modules/perl
1796 ./nginx/core/nginx-1.24.0/src/http/modules
252 ./nginx/core/nginx-1.24.0/src/http/v2
3152 ./nginx/core/nginx-1.24.0/src/http
320 ./nginx/core/nginx-1.24.0/src/mail
8 ./nginx/core/nginx-1.24.0/src/misc
420 ./nginx/core/nginx-1.24.0/src/os/unix
256 ./nginx/core/nginx-1.24.0/src/os/win32
676 ./nginx/core/nginx-1.24.0/src/os
600 ./nginx/core/nginx-1.24.0/src/stream
6220 ./nginx/core/nginx-1.24.0/src
8 ./nginx/core/nginx-1.24.0/html
8 ./nginx/core/nginx-1.24.0/man
44 ./nginx/core/nginx-1.24.0/objs
7684 ./nginx/core/nginx-1.24.0
8772 ./nginx/core
8772 ./nginx
3315748 .
最后一行表示: 当前目录的文件共占用的空间 默认单位为KB
du -h命令:以可读的格式显示当前目录中个文件使用情况,如显示为 KB、MB 或者 GB
[root@ypcvm ~]# du -h
4.0K ./.cache/abrt
4.0K ./.cache
0 ./.config/abrt
0 ./.config
0 ./.pki/nssdb
0 ./.pki
0 ./.docker/buildx/instances
0 ./.docker/buildx/defaults
4.0K ./.docker/buildx/activity
8.0K ./.docker/buildx
8.0K ./.docker
192M ./mongodb-linux-x86_64-rhel70-4.4.9/bin
193M ./mongodb-linux-x86_64-rhel70-4.4.9
48K ./nginx/core/nginx-1.24.0/auto/cc
4.0K ./nginx/core/nginx-1.24.0/auto/lib/geoip
4.0K ./nginx/core/nginx-1.24.0/auto/lib/google-perftools
8.0K ./nginx/core/nginx-1.24.0/auto/lib/libatomic
4.0K ./nginx/core/nginx-1.24.0/auto/lib/libgd
4.0K ./nginx/core/nginx-1.24.0/auto/lib/libxslt
20K ./nginx/core/nginx-1.24.0/auto/lib/openssl
28K ./nginx/core/nginx-1.24.0/auto/lib/pcre
8.0K ./nginx/core/nginx-1.24.0/auto/lib/perl
20K ./nginx/core/nginx-1.24.0/auto/lib/zlib
108K ./nginx/core/nginx-1.24.0/auto/lib
28K ./nginx/core/nginx-1.24.0/auto/os
16K ./nginx/core/nginx-1.24.0/auto/types
392K ./nginx/core/nginx-1.24.0/auto
40K ./nginx/core/nginx-1.24.0/conf
20K ./nginx/core/nginx-1.24.0/contrib/unicode2nginx
4.0K ./nginx/core/nginx-1.24.0/contrib/vim/ftdetect
4.0K ./nginx/core/nginx-1.24.0/contrib/vim/ftplugin
4.0K ./nginx/core/nginx-1.24.0/contrib/vim/indent
116K ./nginx/core/nginx-1.24.0/contrib/vim/syntax
128K ./nginx/core/nginx-1.24.0/contrib/vim
156K ./nginx/core/nginx-1.24.0/contrib
912K ./nginx/core/nginx-1.24.0/src/core
152K ./nginx/core/nginx-1.24.0/src/event/modules
552K ./nginx/core/nginx-1.24.0/src/event
72K ./nginx/core/nginx-1.24.0/src/http/modules/perl
1.8M ./nginx/core/nginx-1.24.0/src/http/modules
252K ./nginx/core/nginx-1.24.0/src/http/v2
3.1M ./nginx/core/nginx-1.24.0/src/http
320K ./nginx/core/nginx-1.24.0/src/mail
8.0K ./nginx/core/nginx-1.24.0/src/misc
420K ./nginx/core/nginx-1.24.0/src/os/unix
256K ./nginx/core/nginx-1.24.0/src/os/win32
676K ./nginx/core/nginx-1.24.0/src/os
600K ./nginx/core/nginx-1.24.0/src/stream
6.1M ./nginx/core/nginx-1.24.0/src
8.0K ./nginx/core/nginx-1.24.0/html
8.0K ./nginx/core/nginx-1.24.0/man
44K ./nginx/core/nginx-1.24.0/objs
7.6M ./nginx/core/nginx-1.24.0
8.6M ./nginx/core
8.6M ./nginx
3.2G .
du -sh命令:显示当前目录所占的总空间大小,不展示里面包含的具体文件的大小
[root@ypcvm ~]# du -sh
3.2G
du -sh --time * :查看当前目录下所有文件与目录的大小与更新时间
[root@ypcvm ~]# du -sh --time *
4.0K 2023-01-12 22:54 anaconda-ks.cfg
823M 2023-03-12 15:14 es7.12.1.tar
4.0K 2023-05-22 16:07 hello.txt
641M 2023-07-06 17:10 jdk.tar
1.1G 2023-03-12 15:20 kibana7.12.1.tar
193M 2023-08-16 09:54 mongodb-linux-x86_64-rhel70-4.4.9
69M 2021-09-20 04:25 mongodb-linux-x86_64-rhel70-4.4.9.tgz
247M 2023-07-06 17:09 mq.tar
8.6M 2023-09-01 14:06 nginx
140M 2023-03-12 10:29 nginx.tar
4.0K 2023-05-22 16:00 test.txt
du -sh * : 查看当前目录下所有文件与目录的大小
[root@ypcvm ~]# du -sh *
4.0K anaconda-ks.cfg
823M es7.12.1.tar
4.0K hello.txt
641M jdk.tar
1.1G kibana7.12.1.tar
193M mongodb-linux-x86_64-rhel70-4.4.9
69M mongodb-linux-x86_64-rhel70-4.4.9.tgz
247M mq.tar
8.6M nginx
140M nginx.tar
4.0K test.txt
du -sh * | sort -rh : (从大到小降序)查看当前目录下所有文件与目录的大小
[root@ypcvm ~]# du -sh * | sort -rh
1.1G kibana7.12.1.tar
823M es7.12.1.tar
641M jdk.tar
247M mq.tar
193M mongodb-linux-x86_64-rhel70-4.4.9
140M nginx.tar
69M mongodb-linux-x86_64-rhel70-4.4.9.tgz
8.6M nginx
4.0K test.txt
4.0K hello.txt
4.0K anaconda-ks.cfg