随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)、博主微信(guyun297890152)、QQ技术交流群(183198395)。
一、功能说明:显示磁盘的相关信息。
二、语法:df [-ahHiklmPT][--block-size=<区块大小>][-t <文件系统类型>][-x <文件系统类型>][--help][--no-sync][--sync][--version][文件或设备]
三、补充说明:df可显示磁盘的文件系统与使用情形。
四、具体事例:
1、-a或--all 包含全部的文件系统。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808452 37377380 5% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
tmpfs 509164 0 509164 0% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
none 0 0 0 - /proc/xen
2、--block-size=<区块大小> 以指定的区块大小来显示区块数目。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --block-size=10240
Filesystem 10K-blocks Used Available Use% Mounted on
/dev/xvda1 4128288 180846 3737738 5% /
tmpfs 50917 0 50917 0% /dev/shm
3、-h或--human-readable 以可读性较高的方式来显示信息。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 40G 1.8G 36G 5% /
tmpfs 498M 0 498M 0% /dev/shm
4、-H或--si 与-h参数相同,但在计算时是以1000 Bytes为换算单位而非1024 Bytes。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 43G 1.9G 39G 5% /
tmpfs 522M 0 522M 0% /dev/shm
5、-i或--inodes 显示inode的信息。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 2621440 48349 2573091 2% /
tmpfs 127291 1 127290 1% /dev/shm
6、-k或--kilobytes 指定区块大小为1024字节。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808456 37377376 5% /
tmpfs 509164 0 509164 0% /dev/shm
7、-l或--local 仅显示本地端的文件系统。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808456 37377376 5% /
tmpfs 509164 0 509164 0% /dev/shm
8、-m或--megabytes 指定区块大小为1048576字节。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/xvda1 40316 1767 36502 5% /
tmpfs 498 0 498 0% /dev/shm
9、--no-sync 在取得磁盘使用信息前,不要执行sync指令,此为预设值。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --no-sync
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808460 37377372 5% /
tmpfs 509164 0 509164 0% /dev/shm
10、-P或--portability 使用POSIX的输出格式。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -P
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/xvda1 41282880 1808460 37377372 5% /
tmpfs 509164 0 509164 0% /dev/shm
11、--sync 在取得磁盘使用信息前,先执行sync指令。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --sync
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808460 37377372 5% /
tmpfs 509164 0 509164 0% /dev/shm
12、-t<文件系统类型>或--type=<文件系统类型> 仅显示指定文件系统类型的磁盘信息。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -t tmpfs
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 509164 0 509164 0% /dev/shm
13、-T或--print-type 显示文件系统的类型。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/xvda1 ext3 41282880 1808468 37377364 5% /
tmpfs tmpfs 509164 0 509164 0% /dev/shm
14、-x<文件系统类型>或--exclude-type=<文件系统类型> 不要显示指定文件系统类型的磁盘信息。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df -x tmpfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808468 37377364 5% /
15、--direct show statistics for a file instead of mount point
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --direct
Filesystem 1K-blocks Used Available Use% File
/dev/xvda1 41282880 1808468 37377364 5% /
tmpfs 509164 0 509164 0% /dev/shm
16、 --total produce a grand total
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --total
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 41282880 1808468 37377364 5% /
tmpfs 509164 0 509164 0% /dev/shm
total 41792044 1808468 37886528 5%
17、--help 显示帮助
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.
Mandatory arguments to long options are mandatory for short options too.
-a, --all include dummy file systems
-B, --block-size=SIZE use SIZE-byte blocks
--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)
-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
-v (ignored)
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
Report df bugs to [email protected]
GNU coreutils home page:
General help using GNU software:
For complete documentation, run: info coreutils 'df invocation'
18、--version 显示版本信息。
[root@iZ2zed6nnllpn4fbw79v1dZ ~]# df --version
df (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjörn Granlund, David MacKenzie, and Paul Eggert.