The df
command is used in Linux to display information about the file system disk space usage. It shows the amount of disk space used and available on all mounted file systems. It is a useful tool for checking disk space usage on both local and remote file systems.
Overview
The basic syntax for the df
command is as follows:
df [OPTION]... [FILE]...
When executed without any options or arguments, df
displays information about all mounted file systems. The output includes the file system device, total size, used space, available space, percentage of used space, and mount point.
Here’s an example of the output:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 10321208 2115788 7670596 22% /
tmpfs 1024000 0 1024000 0% /dev/shm
In the above example, the first column shows the device name, the second column shows the total size of the file system in kilobytes, the third column shows the amount of space used in kilobytes, the fourth column shows the amount of space available in kilobytes, the fifth column shows the percentage of space used, and the last column shows the mount point of the file system.
You can also use the df
command to display information about a specific file system. Simply provide the file system name as an argument to the command:
df /dev/sda1
Options
The following table lists the available options for the df
command:
Option | Description |
---|---|
-a , --all |
Includes all file systems, including those that are not mounted. |
-B , --block-size=SIZE |
Specifies the block size to use for displaying sizes. |
-h , --human-readable |
Displays sizes in a human-readable format, such as “1K”, “2M”, etc. |
-H , --si |
Like -h , but uses powers of 1000 instead of 1024. |
-i , --inodes |
Displays information about the number of inodes used and available on the file system. |
-k , --kilobytes |
Displays sizes in kilobytes. This is the default behavior. |
-l , --local |
Displays information only about local file systems. |
-P , --portability |
Uses the POSIX output format. |
-t , --type=TYPE |
Displays information only about file systems of the specified type. |
-T , --print-type |
Prints the file system type. |
-x , --exclude-type=TYPE |
Excludes file systems of the specified type from the output. |
Troubleshooting Tips
One common issue with the df
command is that it may not display information about a file system if it is not mounted. Make sure to mount the file system before running the df
command.
Another issue is that the output of the df
command may not be up-to-date. This can happen if the file system is being used by another process or if the file system is in the process of being mounted or unmounted. To ensure that the output is up-to-date, use the -P
option to use the POSIX output format.
Notes
The df
command is a useful tool for checking disk space usage on Linux systems. It can be used to display information about all mounted file systems or a specific file system. The available options allow you to customize the output to meet your needs.