linuxIn the
dfThe function of the command is to check
linuxThe disk space footprint of the server’s file system. You can use this command to get information about how much space the hard drive has taken up and how much space is currently left.

The command format

Df [options] [file]

Command function

Displays the free space of the specified disk file. If no file name is specified, the available space for all currently mounted file systems is displayed. By default, disk space will take
1KBDisplay for units, except for environment variables
POSIXLY_CORRECTSpecifies that it will be displayed in 512 bytes.

Command options

  • -a or –all: contains all file systems;
  • –block-size=< block size > : Displays the number of blocks with the specified block size;
  • -h or –human-readable: Display information in a highly readable manner;
  • -h or –si: Same as -h, but calculated in 1000 Bytes instead of 1024 Bytes;
  • -i or –inodes: Displays information about inodes;
  • -k or –kilobytes: Specifies a block size of 1024 bytes;
  • -l or –local: Displays only the local filesystem;
  • -m or –megabytes: Specify a block size of 1048576 bytes;
  • –no-sync: Do not execute the sync command until disk usage information is obtained. This is the default value;
  • -por –portability: Use POSIX’s output format;
  • –sync: Execute the sync instruction before obtaining the disk usage information;
  • -t< file system type > or –type=< file system type > : Displays only disk information of the specified file system type;
  • -t or –print-type: Displays the type of file system;
  • -x< filesystem type > or –exclude-type=< filesystem type > : Do not display information about the specified filesystem type;
  • –help: show help;
  • –version: Displays version information.

View the system disk device. Default is in KB

> df
Filesystem     1K-blocks     Used Available Use% Mounted on
devtmpfs         8122232        0   8122232   0% /dev
tmpfs            8132768       16   8132752   1% /dev/shm
tmpfs            8132768   808464   7324304  10% /run
tmpfs            8132768        0   8132768   0% /sys/fs/cgroup
/dev/vda1       41921520 32260888   9660632  77% /
/dev/vdb1      206291944 20278964 175510888  11% /data
tmpfs            1626556        0   1626556   0% /run/user/0
tmpfs            1626556        0   1626556   0% /run/user/1004

The first column in the output list of the df command in Linux is the pathname of the device file (typically the partition on the hard disk) that represents the file system. Column 2 gives the number of data blocks (1024 bytes) that the partition contains. Columns 3 and 4 represent the number of used and available data blocks, respectively. The user might be surprised that the sum of the blocks in columns 3 and 4 does not equal the number of blocks in column 2. This is because each partition by default leaves a small amount of space for the system administrator to use. Even when the normal user space is full, the administrator can still log in and have the workspace needed to resolve the problem. The USE % column in the listing represents the percentage of common user space used, and even if this number reaches 100%, the partition still has room for system administrators. Finally, the Mounted on column indicates the mount points of the file system.

Displays disk usage in inode mode

> df -i Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 2030558 372 2030186 1% /dev tmpfs 2033192 4 2033188 1% /dev/shm tmpfs 2033192 662 2032530 1% /run tmpfs 2033192 16 2033176 1% /sys/fs/cgroup /dev/vda1 19476336 154836 19321500  1% / /dev/vdb1 13107200 323757 12783443 3% /data tmpfs 2033192 1 2033191 1% /run/user/0 tmpfs 2033192 1 2033191 1% /run/user/1004

Displays a disk of the specified type

> df -t ext4
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vdb1      206291944 20278964 175510888  11% /data

Printing in addition toext4All external file systems

> df -x ext4
Filesystem     1K-blocks     Used Available Use% Mounted on
devtmpfs         8122232        0   8122232   0% /dev
tmpfs            8132768       16   8132752   1% /dev/shm
tmpfs            8132768   808464   7324304  10% /run
tmpfs            8132768        0   8132768   0% /sys/fs/cgroup
/dev/vda1       41921520 32260804   9660716  77% /
tmpfs            1626556        0   1626556   0% /run/user/0
tmpfs            1626556        0   1626556   0% /run/user/1004

List the I node usage of each file system

> df -ia
Filesystem       Inodes  IUsed    IFree IUse% Mounted on
sysfs                 0      0        0     - /sys
proc                  0      0        0     - /proc
devtmpfs        2030558    372  2030186    1% /dev
securityfs            0      0        0     - /sys/kernel/security
tmpfs           2033192      4  2033188    1% /dev/shm
devpts                0      0        0     - /dev/pts
tmpfs           2033192    662  2032530    1% /run
tmpfs           2033192     16  2033176    1% /sys/fs/cgroup
cgroup                0      0        0     - /sys/fs/cgroup/systemd
pstore                0      0        0     - /sys/fs/pstore
cgroup                0      0        0     - /sys/fs/cgroup/perf_event
cgroup                0      0        0     - /sys/fs/cgroup/net_cls,net_prio
cgroup                0      0        0     - /sys/fs/cgroup/pids
cgroup                0      0        0     - /sys/fs/cgroup/devices
cgroup                0      0        0     - /sys/fs/cgroup/freezer
cgroup                0      0        0     - /sys/fs/cgroup/blkio
cgroup                0      0        0     - /sys/fs/cgroup/cpu,cpuacct
cgroup                0      0        0     - /sys/fs/cgroup/hugetlb
cgroup                0      0        0     - /sys/fs/cgroup/memory
cgroup                0      0        0     - /sys/fs/cgroup/cpuset
configfs              0      0        0     - /sys/kernel/config
/dev/vda1      19476376 154836 19321540    1% /
systemd-1             -      -        -     - /proc/sys/fs/binfmt_misc
mqueue                0      0        0     - /dev/mqueue
debugfs               0      0        0     - /sys/kernel/debug
hugetlbfs             0      0        0     - /dev/hugepages
/dev/vdb1      13107200 323757 12783443    3% /data
tmpfs           2033192      1  2033191    1% /run/user/0
binfmt_misc           0      0        0     - /proc/sys/fs/binfmt_misc
tmpfs           2033192      1  2033191    1% /run/user/1004

Lists file system types

> df -T Filesystem Type 1K-blocks Used Available Use% Mounted on devtmpfs devtmpfs 8122232 0 8122232 0% /dev tmpfs tmpfs  8132768 16 8132752 1% /dev/shm tmpfs tmpfs 8132768 808464 7324304 10% /run tmpfs tmpfs 8132768 0 8132768 0% /sys/fs/cgroup /dev/vda1 xfs 41921520 32261336 9660184 77% / /dev/vdb1 ext4 206291944 20278972 175510880 11% /data tmpfs  tmpfs 1626556 0 1626556 0% /run/user/0 tmpfs tmpfs 1626556 0 1626556 0% /run/user/1004

Displays current disk space and usage in a more readable manner

> df-h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.8g 0 7.8g 0% /dev TMPFS 7.8g 16K 7.8g 1% /dev/ SHM TMPFS 7.8g 790M 7.0g 10% /run TMPFS 7.8g 0 7.8g 0% /sys/fs/cgroup /dev/vda1 40G 31G 9.3g 77% / /dev/vdb1 197G 20G 168G 11% /data TMPFS 1.6g 0 1.6g 0% /run/user/0 TMPFS 1.6g 0 1.6g 0% /run/user/1004 > df-h Filesystem Size Used Avail Use% Mounted on devtmpfs 8.4g 0 8.4g 0% /dev TMPFS 8.4g 17k 8.4g 1% /dev/ SHM TMPFS 8.4g 828M 7.6g 10% /run TMPFS 8.4g 0 8.4g 0% /sys/fs/cgroup /dev/vda1 43G 34G 9.9g 77% / /dev/vdb1 212G 21G 180G 11% /data TMPFS 1.7g 0 1.7g 0% /run/user/0 TMPFS 1.7g 0 1.7g 0 1.7g 0% /run/user/1004 > df-lh Filesystem Size Used Avail Use% Mounted on devtmpfs 7.8g 0 7.8g 0% /dev TMPFS 7.8g 16K 7.8g 1% /dev/shm TMPFS 7.8g 790M 7.0g 10% /run TMPFS 7.8g 0 7.8g 0% /sys/fs/cgroup /dev/vda1 40G 31G 9.3g 77% / /dev/vdb1 197G 20G 168G 11% /data TMPFS 1.6g 0 1.6g 0% /run/user/0 TMPFS 1.6g 0 1.6g 0% /run/user/1004 > df -k Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 8122232 0 8122232 0% /dev tmpfs 8132768 16 8132752 1% /dev/shm tmpfs 8132768 808464 7324304 10% /run tmpfs 8132768 0 8132768 0% /sys/fs/cgroup /dev/vda1 41921520 32259084 9662436 77% / /dev/vdb1 206291944 20278972 175510880 11% /data tmpfs 1626556 0 1626556 0% /run/user/0 tmpfs 1626556 0 1626556 0% /run/user/1004
  • -h displays current disk space and usage in a more readable manner
  • The -h parameter above the -h root is the same, but when the root is converted, 1000 is used instead of 1024 for the capacity conversion
  • -k Displays disk usage in units
  • -l shows the disk space usage of the local partition. If the server NFS the disk of the remote server, the system displays the results after filtering the NSF drive by adding -l to the df
  • -i shows the inode usage. Linux manages disk space mapping in a pointerlike way. This is also a key application

The original link: https://rumenz.com/rumenbiji/… WeChat official account: entry station