Linux common commands: df command


  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 - block used free used % mount point

/dev/sda7              19840892     890896   17925856    5 % /

/ dev / sda9             203727156  112797500   80413912   59 % / opt

/dev/sda8               4956284     570080    4130372   13 % / var

/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 indicates the percentage of normal user space used, and even if this number reaches 100%, the partition still has space left for the system administrator 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

Filesystem Inode (I) Used (I) Available (I) Used % mount point

/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

illustrate:

 

Example 3: Display the specified type of disk

Order:

  df -t ext3

output:

[root@CT1190 log]# df -t ext3

filesystem 1K - block used free used % mount point

/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

 illustrate:

 

Example 4: List i-node usage for each file system

Order:

  df -ia

output:

[root@CT1190 log]# df -ia

Filesystem Inode (I) Used (I) Available (I) Used % mount point

/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

illustrate:

 

Example 5: List the types of filesystems

Order:

  df -T

output:

root@CT1190 log]# df -T

filesystem type 1K - block used free used % mount point

/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

illustrate:

 

Example 6: Display current disk space and usage in a more readable way 

Order:

output:

[root@CT1190 log]# df -h

filesystem capacity used free used % mount point

/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

filesystem capacity used free used % mount point

/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

filesystem capacity used free used % mount point

/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

filesystem 1K - block used free used % mount point

/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

illustrate:

-h shows current disk space and usage in a more readable way

The -h parameter above the -H root is the same, but when rooting, 1000 is used instead of 1024 for capacity conversion

-k show disk usage in units

-l displays the disk space usage of the local partition, if the server nfs the disk of the remote server, then after adding -l to df, the system displays the result after filtering the nsf drive

-i shows inode usage. Linux uses a pointer-like way to manage disk space mapping. This is also a key application

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325160386&siteId=291194637