The function of the df command in Linux is to check the disk space usage of the file system of the Linux server. You can use this command to obtain information such as how much space is occupied by the hard disk and how much space is left.
1. Command format:
df [options] [files]
2. Command function:
Displays the free space of the specified disk file. If no filename is specified, the free space for all currently mounted filesystems will be displayed. By default, disk space will be displayed in units of 1KB unless the environment variable POSIXLY_CORRECT is specified, in which case it will be displayed in units of 512 bytes
3. Command parameters:
Required parameters:
-a list of all filesystems
-h display in easy-to-read mode
-H is equal to "-h", but the formula, 1K=1000, not 1K=1024
-i show inode information
-k blocks are 1024 bytes
-l show only the local filesystem
-m block is 1048576 bytes
--no-sync ignore sync command
-P output format is POSIX
--sync Execute the sync command before getting the disk information
-T filesystem type
Select parameters:
--block-size=<block size> specify block size
-t <filesystem type> only display disk information for the selected filesystem
-x <filesystem type> Do not display disk information for the selected filesystem
--help display help information
--version display version information
4. Example of use:
Example 1: Displaying disk usage
Order:
df
output:
[root@CT1190 log]# df
filesystem 1K-blocks used free used % mountpoint
/dev/sda7 19840892 890896 17925856 5% /
/ dev / sda9 203727156 112797500 80413912 59% / opt
/dev/sda8 4956284 570080 4130372 13% / yes
/dev/sda6 19840892 1977568 16839184 11% /usr
/dev/sda3 988116 23880 913232 3% /boot
tmpfs 16473212 0 16473212 0% /dev/shm
illustrate:
The first column of the output list of the df command in linux is the path name of the device file corresponding to the file system (usually a partition on the hard disk); the second column gives the number of data blocks (1024 bytes) contained in the partition; the first Columns 3 and 4 indicate the number of used and available data blocks, respectively. Users may find it strange that the sum of the blocks in columns 3 and 4 is not equal to the number of blocks in column 2. This is because by default each partition has a small amount of space reserved for system administrators. Even if the normal user space is full, the administrator can still log in and have the workspace needed to solve the problem. The Use% column in the list represents the percentage of normal user space used, and even if this number reaches 100%, the partition still has space left for system administrators to use. Finally, the Mounted on column represents the mount point of the file system .
Example 2: Display disk usage in inode mode
Order:
df -i
output:
[root@CT1190 log]# df -i
文件系统 Inode (I)已用 (I)可用 (I)已用% 挂载点
/dev/sda7 5124480 5560 5118920 1% /
/dev/sda9 52592640 50519 52542121 1% /opt
/dev/sda8 1280000 8799 1271201 1% /var
/dev/sda6 5124480 80163 5044317 2% /usr
/dev/sda3 255232 34 255198 1% /boot
tmpfs 4118303 1 4118302 1% /dev/shm
说明:
实例3:显示指定类型磁盘
命令:
df -t ext3
输出:
[root@CT1190 log]# df -t ext3
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda7 19840892 890896 17925856 5% /
/dev/sda9 203727156 93089700 100121712 49% /opt
/dev/sda8 4956284 570104 4130348 13% /var
/dev/sda6 19840892 1977568 16839184 11% /usr
/dev/sda3 988116 23880 913232 3% /boot
说明:
实例4:列出各文件系统的i节点使用情况
命令:
df -ia
输出:
[root@CT1190 log]# df -ia
文件系统 Inode (I)已用 (I)可用 (I)已用% 挂载点
/dev/sda7 5124480 5560 5118920 1%
/proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
/dev/sda9 52592640 50519 52542121 1% /opt
/dev/sda8 1280000 8799 1271201 1% /var
/dev/sda6 5124480 80163 5044317 2% /usr
/dev/sda3 255232 34 255198 1% /boot
tmpfs 4118303 1 4118302 1% /dev/shm
none 0 0 0 - /proc/sys/fs/binfmt_misc
说明:
实例5:列出文件系统的类型
命令:
df -T
输出:
root@CT1190 log]# df -T
文件系统 类型 1K-块 已用 可用 已用% 挂载点
/dev/sda7 ext3 19840892 890896 17925856 5% /
/dev/sda9 ext3 203727156 93175692 100035720 49% /opt
/dev/sda8 ext3 4956284 570104 4130348 13% /var
/dev/sda6 ext3 19840892 1977568 16839184 11% /usr
/dev/sda3 ext3 988116 23880 913232 3% /boot
tmpfs tmpfs 16473212 0 16473212 0% /dev/shm
说明:
实例6:以更易读的方式显示目前磁盘空间和使用情况
命令:
输出:
[root@CT1190 log]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda7 19G 871M 18G 5% /
/dev/sda9 195G 89G 96G 49% /opt
/dev/sda8 4.8G 557M 4.0G 13% /var
/dev/sda6 19G 1.9G 17G 11% /usr
/dev/sda3 965M 24M 892M 3% /boot
tmpfs 16G 0 16G 0% /dev/shm
[root@CT1190 log]# df -H
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda7 21G 913M 19G 5% /
/dev/sda9 209G 96G 103G 49% /opt
/dev/sda8 5.1G 584M 4.3G 13% /var
/dev/sda6 21G 2.1G 18G 11% /usr
/dev/sda3 1.1G 25M 936M 3% /boot
tmpfs 17G 0 17G 0% /dev/shm
[root@CT1190 log]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda7 19G 871M 18G 5% /
/dev/sda9 195G 89G 96G 49% /opt
/dev/sda8 4.8G 557M 4.0G 13% /var
/dev/sda6 19G 1.9G 17G 11% /usr
/dev/sda3 965M 24M 892M 3% /boot
tmpfs 16G 0 16G 0% /dev/shm
[root@CT1190 log]# df -k
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda7 19840892 890896 17925856 5% /
/dev/sda9 203727156 93292572 99918840 49% /opt
/dev/sda8 4956284 570188 4130264 13% /var
/dev/sda6 19840892 1977568 16839184 11% /usr
/dev/sda3 988116 23880 913232 3% /boot
tmpfs 16473212 0 16473212 0% /dev/shm
说明:
-h更具目前磁盘空间和使用情况 以更易读的方式显示
-H根上面的-h参数相同,不过在根式化的时候,采用1000而不是1024进行容量转换
-k以单位显示磁盘的使用情况
-l显示本地的分区的磁盘空间使用率,如果服务器nfs了远程服务器的磁盘,那么在df上加上-l后系统显示的是过滤nsf驱动器后的结果
-i显示inode的使用情况。linux采用了类似指针的方式管理磁盘空间影射.这也是一个比较关键应用