Linux df command

Linux 命令大全Linux Commands Reference

The Linux df (full English name: display free disk space) command is used to display disk space usage of the file system, including total capacity, used space, available space, mount points, and other information.

Syntax

df [选项]... [FILE]...
ParametersDescription
-a, --allDisplay all file systems, including virtual file systems (such asproc, sysfs)
-B, --block-size=SIZESpecify the display unit (such as-BK=KB,-BM=MB,-BG=GB)
-h, --human-readableDisplay in human-readable format (automatically converts units: K, M, G, T, based on 1024)
-H, --siSimilar to-h, but uses 1000 as the conversion unit (conforms to SI standard)
-i, --inodesDisplay inode usage (instead of disk space)
-kDisplay in 1KB units (default unit)
-mDisplay in 1MB units (supported by some systems)
-l, --localDisplay only local file systems (exclude network file systems such as NFS)
--no-syncDo not invoke before getting informationsync(default behavior)
--syncInvoke before getting informationsync(ensure data is up to date)
--totalDisplay total information
-t, --type=TYPEOnly display file systems of the specified type (such asext4, xfs)
-T, --print-typeDisplay file system type
-x, --exclude-type=TYPEExclude file systems of the specified type
-P, --portabilityUse POSIX-compatible output format (avoid line break issues)
--output=FIELD_LISTCustom output fields (such assource,fstype,size,pcent)
--helpDisplay help information
--versionDisplay version information

Examples

Display disk usage statistics of the file system:

# df 
Filesystem     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 

Explanation:

  • Filesystem: The name or identifier of the file system.
  • 1K-blocks: The total capacity of the file system, in 1KB blocks. That is, the total size of the file system.
  • Used: The capacity already used by the file system, in 1KB blocks.
  • Available: The capacity still available in the file system, in 1KB blocks.
  • Use%: The percentage of the file system's used capacity to its total capacity.
  • Mounted on: The directory or location where the file system is mounted.

-hThe option will display disk space usage in a human-readable way:

# df -h 
Filesystem      Size  Used   Avail Use% Mounted on 
/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 

df can also display file system information of disk usage:

# df test 
Filesystem     1K-blocks    Used      Available Use% Mounted on 
/dev/sda6       29640780    4320600   23814492  16%       / 

The output of the df command with the -i option displays inode information instead of block usage.

df -i 
Filesystem      Inodes    IUsed    IFree     IUse% Mounted on 
/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 

Display all information:

# df --total 
Filesystem     1K-blocks    Used    Available Use% Mounted on 
/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 
total           33344320 4321772    27516860  14% 

We see that the end of the output contains an additional line showing the total for each column.

We can see the output displays the numeric forms 'G' (gigabytes), 'M' (megabytes), and 'K' (kilobytes).

Linux 命令大全Linux Commands Reference

Other Extensions