Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux df command

Linux df command

Linux Command Reference Linux Command Reference

Linux df (short for display free disk space) is used to show the disk space usage of file systems, including total capacity, used space, available space, and mount points.

Syntax

df [选项]... [FILE]...

Parameters Description
-a, --all Display all file systems, including virtual file systems (such as proc, sysfs)
-B, --block-size=SIZE Specify the display unit (such as -BK=KB, -BM=MB, -BG=GB)
-h, --human-readable Display in a human-readable format (automatically converts units: K, M, G, T, based on 1024)
-H, --si Similar to -h, but using 1000 as the conversion unit (compliant with the SI standard)
-i, --inodes Display inode usage (instead of disk space)
-k Display in 1KB units (default)
-m Display in 1MB units (supported on some systems)
-l, --local Display only local file systems (excluding network file systems such as NFS)
--no-sync Do not call syncbefore getting information (default behavior)
--sync Call syncbefore getting information (ensures up-to-date data)
--total Display total information
-t, --type=TYPE Display only file systems of the specified type (such as ext4, xfs)
-T, --print-type Display the file system type
-x, --exclude-type=TYPE Exclude file systems of the specified type
-P, --portability Use a POSIX-compatible output format (to avoid line-wrapping issues)
--output=FIELD_LIST Customize output fields (such as source,fstype,size,pcent)
--help Display help information
--version Display version information

Example

Display disk usage statistics for file systems:



# 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:

The -h option displays 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 the file system information of disk usage:



# df test 

Filesystem     1K-blocks    Used      Available Use% Mounted on 

/dev/sda6       29640780    4320600   23814492  16%       / 

Using 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 can see that the end of the output contains an extra row showing the totals for each column.

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

Linux Command Reference Linux Command Reference