1. 命令解析
命令用途:
查看磁盘使用及剩余空间情况
命令格式:
df [OPTION]... [FILE]...
命令参数:
-a, --all include dummy file systems
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
--direct show statistics for a file instead of mount point
--total produce a grand total
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si likewise, but use powers of 1000 not 1024
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
--output[=FIELD_LIST] use the output format defined by FIELD_LIST,
or print all fields if FIELD_LIST is omitted.
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
2. 示例
2.1 查看信息
[root@test test]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 25670884 2503564 21840268 11% /
devtmpfs 1934228 0 1934228 0% /dev
tmpfs 1939484 0 1939484 0% /dev/shm
tmpfs 1939484 210684 1728800 11% /run
tmpfs 1939484 0 1939484 0% /sys/fs/cgroup
/dev/vdc1 103079868 61044 97759632 1% /data
2.2 指定单位 -B
[root@test test]# df -B K
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 25670884K 2503548K 21840284K 11% /
devtmpfs 1934228K 0K 1934228K 0% /dev
tmpfs 1939484K 0K 1939484K 0% /dev/shm
tmpfs 1939484K 210684K 1728800K 11% /run
tmpfs 1939484K 0K 1939484K 0% /sys/fs/cgroup
/dev/vdc1 103079868K 61044K 97759632K 1% /data
[root@test test]# df -B M
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/vda1 25070M 2445M 21329M 11% /
devtmpfs 1889M 0M 1889M 0% /dev
tmpfs 1895M 0M 1895M 0% /dev/shm
tmpfs 1895M 206M 1689M 11% /run
tmpfs 1895M 0M 1895M 0% /sys/fs/cgroup
/dev/vdc1 100664M 60M 95469M 1% /data
[root@test test]# df -B G
Filesystem 1G-blocks Used Available Use% Mounted on
/dev/vda1 25G 3G 21G 11% /
devtmpfs 2G 0G 2G 0% /dev
tmpfs 2G 0G 2G 0% /dev/shm
tmpfs 2G 1G 2G 11% /run
tmpfs 2G 0G 2G 0% /sys/fs/cgroup
/dev/vdc1 99G 1G 94G 1% /data
2.3 以友好的方式展示 -h
[root@test test]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 25G 2.4G 21G 11% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 206M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vdc1 99G 60M 94G 1% /data
2.4 显示inode信息 -i
[root@test test]# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 1.6M 72K 1.5M 5% /
devtmpfs 473K 328 472K 1% /dev
tmpfs 474K 1 474K 1% /dev/shm
tmpfs 474K 356 474K 1% /run
tmpfs 474K 13 474K 1% /sys/fs/cgroup
/dev/vdc1 6.3M 11 6.3M 1% /data
2.5 显示文件系统类型 -T
[root@test test]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/vda1 ext4 25670884 2503600 21840232 11% /
devtmpfs devtmpfs 1934228 0 1934228 0% /dev
tmpfs tmpfs 1939484 0 1939484 0% /dev/shm
tmpfs tmpfs 1939484 210684 1728800 11% /run
tmpfs tmpfs 1939484 0 1939484 0% /sys/fs/cgro
2.6 显示特定文件类型 -t
[root@test test]# df -t ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 25670884 2503624 21840208 11% /
/dev/vdc1 103079868 61044 97759632 1% /data
2.7 不显示特定文件类型 -x
[root@test test]# df -x ext4
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1934228 0 1934228 0% /dev
tmpfs 1939484 0 1939484 0% /dev/shm
tmpfs 1939484 210684 1728800 11% /run
tmpfs 1939484 0 1939484 0% /sys/fs/cgroup