English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux df command

Linux 命令大全

The Linux df command (full name in English: disk free) is used to display statistics of file system disk usage on the current Linux system.

Syntax

df [options]... [FILE]...
  • File-a, --all Include all file systems with 0 Blocks
  • File--block-size={SIZE} Use {SIZE} size Blocks
  • File-h, --human-readable Use human-readable format (the default is not to add this option...)
  • File-H, --si Like -h, but using 1000 instead of using 1024
  • File-i, --inodes List inode information, do not list used blocks
  • File-k, --kilobytes Like --block-size=1024
  • File-l, --local Limit the file structure listed
  • File-m, --megabytes Like --block-size=1048576
  • File--no-sync Do not sync before getting information (default)
  • File-P, --portability Use POSIX output format
  • File--sync Sync before getting information
  • File-t, --type=TYPE Limit the file systems listed to TYPE
  • File-T, --print-type Display the format of the file system
  • File-x, --exclude-type=TYPE Limit the file systems listed to not display TYPE
  • File-v (ignore)
  • File--help Display this help and exit
  • File--version Output version information and exit

Online example

Display statistics of disk usage of the file system:

# df 
文件系统     1K-blocks    Used     Available Use% Mounted on 
/dev/sda6       29640780 4320704     23814388  16%     / 
udev             1536756       4     1536752    1%     /dev 
tmpfs             617620     888     616732     1%     /run 
none                5120       0     5120       0%     /run/lock 
none             1544044     156     1543888    1%     /run/shm 

The first column specifies the name of the file system, and the second column specifies a specific file system1K-block1K is1024Total memory in bytes. The columns "used" and "available" specify the amount of memory in use.

Use the column to specify the percentage of memory used, while the last column "mounted on" specifies the mount point of the file system.

df也可以显示磁盘使用的文件系统信息:

# df test 
文件系统     1K-块    已用      可用 使用% 挂载于 
/dev/sda6       29640780    4320600   23814492  16%       / 

用一个-i选项的df命令输出显示索引节点信息而非块使用量。

df -i 
文件系统      索引节点    已用    可用 使用% 挂载于 
/dev/sda6      1884160    261964   1622196   14%        / 
udev           212748     560      212188    1%         /dev 
tmpfs          216392     477      215915    1%         /run 
none           216392     3        216389    1%         /run/lock 
none           216392     8        216384    1%         /run/shm 

显示所有信息:

# df --总计 
文件系统     1K-块    已用    可用 使用% 挂载于 
/dev/sda6       29640780 4320720    23814372  16%     / 
udev             1536756       4    1536752   1%      /dev 
tmpfs             617620     892    616728    1%      /run 
none                5120       0    5120      0%      /run/lock 
none             1544044     156    1543888   1%      /run/shm 
总计           33344320 4321772    27516860  14% 

我们看到输出的末尾,包含一个额外的行,显示每一列的总计。

-h选项,通过它可以产生可读格式的df命令输出:

# df -h 
文件系统      大小  已用   可用 使用% 挂载于 
/dev/sda6       29G   4.2G   23G   16%     / 
udev            1.5G  4.0K   1.5G   1%     /dev 
tmpfs           604M  892K   603M   1%     /run 
none            5.0M     0   5.0M   0%     /run/lock 
none            1.5G  156K   1.5G   1%     /run/shm 

我们可以看到输出显示的数字形式的'G'(千兆字节),"M"(兆字节)和"K"(千字节)。

这使得输出易于阅读和理解,从而使显示可读。请注意,第二列的名称也发生了变化,为了使显示可读的“大小”。

Linux 命令大全