What is the df Command in Linux? – 9 Practical Examples

df-command-in-Linux

The df command in Linux stands for ‘disk filesystem.’ The command summarizes the disk space available on a file system. The df command is used alongside the du command. However, the du command focuses on the disk usage for files and directories. Read more on how to use the du command.

As a Linux admin or someone looking to understand what’s taking up space and stay alert on the used and available disk space, understanding the df command is inevitable. We’ve presented a detailed guide on the df command, giving examples of how to use it.

Syntax of the df Command in Linux and Its Options

Any user can use the Linux df command and follow the below syntax.

The table below displays some options for running the df command.

OptionDescription
-a or –allIt is added to include all file systems in the output.
-h or –human-readableIt is added to display the output in a more human-readable format.
-TIt is included to show the file system type.
-tIt is added to restrict the output to a specific file system.
-xIt is added to exclude a specific file system in the output.
–totalIt is added to show the total available space for all entries.
-iIt displays inode information and not the block usage.
-BIt is added to scale the sizes by SIZE before showing the output.
-lIt is included to limit the listing to the local file systems only.

df Command in Linux with Examples

The results of using the Linux df command will depend on the options you include. We’ve already listed the commonly used options. The next step is to cover examples of how to use the df command.

1. Basic df Command Usage

When you run the df command without adding any option or specifying the target file system, it will display information for the currently mounted file systems.

The output will be presented in a table format. The ‘Filesystem’ shows the name of each mounted storage device. The ‘1K-blocks/Size’ shows the total size for that filesystem. The ‘Used’ represents the disk space occupied by data in the filesystem.

The ‘Available’ represents the free space, while the ‘Use%’ is a percentage of the space used by that filesystem. The ‘Mounted on’ is the location where the filesystem is mounted.

df-command-in-Linux

2. df Command in Linux Show Summary on All File Systems

When you add the -a option, the report will include information on all file systems, not just the mounted ones.

df-command-show-all-filesystems

3. Display Human Readable Output

The df command output is not readable. However, adding the -h option gives a better output, and the sizes are shown in powers of 1024, including G (gigabytes), M(megabytes), K(kilobytes), etc.

human-readable-output

4. df Command in Linux Include Filesystem Types

In the output we’ve extracted in the previous examples, we can’t tell the type of the displayed file systems. Luckily, the df command offers the -T option to include the file system type in the output.

Notice how next to the filesystem, we have its type.

5. Show Total Available Space

If you want to see the total of different metrics of the displayed file systems, add the –total. For instance, it will show the total used and available space.

For our example, we’ve included the -h option, and we target all the mounted file systems.

df-sommand-show-total-space

6. Specifying a Target Mount

You can add a target mount to view its disk usage. For instance, to use the /boot/, we would run our command as follows.

df-command-specify-mount

7. df Command in Linux Include inodes

The -i option specifies to include the index node (inode) on each mounted filesystem.

df-command-include-inodes

8. Check Disk Space Usage of Specific File System Type

Instead of showing information for all filesystem types, you can limit the output to a specific type by adding the -t option.

Assuming you only want to check for ext4 filesystem type, our command would be as follows.

df-command-check-specific-filesystem-type

9. Excluding File System Types

You don’t have to include all file system types in your output. Similar to how we’ve specified to show results for a particular file system type, it’s possible to exclude a file system type. For that, we use the -x option.

The output below shows the difference between the outputs when we include all file system types and exclude the tmpfs type.

df-command-exclude-filesystems

Conclusion

The df command in Linux helps check disk usage for file systems. You can utilize the df command in numerous ways, and this post has shared some of these ways by giving 9 practical examples. Have fun using the df command in Linux.

Found this helpful? - Share it!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top