Linux df command
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]...
| Parameters | Description |
|---|---|
-a, --all | Display all file systems, including virtual file systems (such asproc, sysfs) |
-B, --block-size=SIZE | Specify the display unit (such as-BK=KB,-BM=MB,-BG=GB) |
-h, --human-readable | Display in human-readable format (automatically converts units: K, M, G, T, based on 1024) |
-H, --si | Similar to-h, but uses 1000 as the conversion unit (conforms to SI standard) |
-i, --inodes | Display inode usage (instead of disk space) |
-k | Display in 1KB units (default unit) |
-m | Display in 1MB units (supported by some systems) |
-l, --local | Display only local file systems (exclude network file systems such as NFS) |
--no-sync | Do not invoke before getting informationsync(default behavior) |
--sync | Invoke before getting informationsync(ensure data is up to date) |
--total | Display total information |
-t, --type=TYPE | Only display file systems of the specified type (such asext4, xfs) |
-T, --print-type | Display file system type |
-x, --exclude-type=TYPE | Exclude file systems of the specified type |
-P, --portability | Use POSIX-compatible output format (avoid line break issues) |
--output=FIELD_LIST | Custom output fields (such assource,fstype,size,pcent) |
--help | Display help information |
--version | Display 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).
Other Extensions
Linux Commands Reference