【Linux】命令 - df

Posted by 西维蜀黍 on 2021-10-21, Last Modified on 2023-02-16

Usage

# Display all filesystems and their disk usage:
$ df

# Display all filesystems and their disk usage in human readable form:
$ df -h

# Display the filesystem and its disk usage containing the given file or directory:
$ df path/to/file_or_directory

# Display statistics on the number of free inodes:
$ df -i

# Display filesystems but exclude the specified types:
$ df -x squashfs -x tmpfs

-h

查看文件系统磁盘空间的使用情况

$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               451M     0  451M   0% /dev
tmpfs                               97M  1.3M   96M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.9G  3.4G  287M  93% /
tmpfs                              482M     0  482M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              482M     0  482M   0% /sys/fs/cgroup
/dev/loop0                          92M   92M     0 100% /snap/core/8689
/dev/loop1                          90M   90M     0 100% /snap/core/8268
/dev/sda2                          976M   77M  832M   9% /boot
tmpfs                               97M     0   97M   0% /run/user/0

-i

$ df -i
Filesystem                         Inodes  IUsed   IFree IUse% Mounted on
udev                               492307    467  491840    1% /dev
tmpfs                              503596    711  502885    1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 9601024 339292 9261732    4% /
tmpfs                              503596      4  503592    1% /dev/shm
tmpfs                              503596      3  503593    1% /run/lock
tmpfs                              503596     18  503578    1% /sys/fs/cgroup
/dev/sda2                           65536    308   65228    1% /boot
/dev/sda1                               0      0       0     - /boot/efi
/dev/loop1                          10803  10803       0  100% /snap/core18/2128
/dev/loop2                          11720  11720       0  100% /snap/core20/1081
/dev/loop0                          10809  10809       0  100% /snap/core18/1944
/dev/loop3                          11732  11732       0  100% /snap/core20/1169
/dev/loop4                           1602   1602       0  100% /snap/lxd/21029
/dev/loop5                            796    796       0  100% /snap/lxd/21545
/dev/loop7                            474    474       0  100% /snap/snapd/13270
tmpfs                              503596     91  503505    1% /run/user/1000
/dev/loop8                            479    479       0  100% /snap/snapd/13640

The output gives us:

  • File system: The file system being reported on.
  • Inodes: The total number of inodes in this file system.
  • IUsed: The number of inodes in use.
  • IFree: The number of remaining inodes available for use.
  • IUse%: The percentage of used inodes.
  • Mounted on: The mount point for this file system.

Reference