11 'df' command to check disk space in Linux with examples

This article will help you understand the use of df command in Linux and how to use df command with multiple options in Linux/Unix. The 'df' (Disk Free) command is in an inbuilt utility to find the available and disk usage space on Linux servers/storage. This command is mainly used by all the System Admins, as it is one of their main tasks to monitor the server/storage space. Don't be confused with df and du command. Check here " how to use the du command in Linux with examples"

This guide will help you on how to use the df command in Linux with options and examples. All the below examples were tested on RHEL/CENTOS 7.6

Global Syntax of df command in Linux:

df [OPTION]...  [FILE]...

The following table provides an overview of the options of df command in Linux.

df command in linux with options

1. How to check the details of disk space used in each file system?

# df

what is df command in linuxNote: Using the 'df' command without any option/parameter will display all the partitions and the usage information of the disk space. The result of the above command contains 6 columns which are explained here below:

Filesystem           -->      Mount Point Name
1K-blocks            -->     Available total space counted in 1kB (1000 bytes)
Used                    -->     Used block size
Available            -->    Free blocks size
Use%                  -->   Usage on percentage-wise
Mounted on       -->   Show the path of the mounted point

# df -k

df command in linux manualNote: Even using the '-k' option also provides the same output as the default 'df' command. Both outputs provide the same data usage of file systems in block size which is measured in 1024 bytes.

2. How to check the information of all the file system disk space?

# df -a

df command in linux for a directoryNote: The result of the above command is the same as the previous output, but here the '-a' option will list even all the fake/not-real filesystem along with the real files. As we know, Linux always creates and populates file systems based on the running functionalities, it is called a pseudo file system (means it will always create fake/not-real files based on its currently running system) and it will not appear in the rootfs file system of the distro image. Eg: proc,sysfs,etc.

3. How to check the disk space in Human-Readable format?

# df -h

df command in linux sort by sizeNote: Using the'-h' option will list all the outputs in a "Human Readable Format". You can see the results of all the disk space of my previous examples measured in bytes, which are difficult to read. You can see this example, it measures all the sizes in GB which is easy to understand. Reading the sizes in MB, GB, and TB is much easier than the KB. The '-h' human-readable format used the power of 1024.

# df -H

df command in linux rootNote: Using the '-H' option will list all the sizes in power of 1000, you can see the difference in the size of disk space of using "df -h and df -H".

4. How to sum up the total disk space usage?

# df -h --total

df command folder sizeNote: using '--total' along with '-h' will sum up the total disk usage of all the file systems.

5. How to list the Inodes information for all file systems?

# df -i

df command to find inode in linuxNote: Using '-i' will list the information about the Inodes of all the filesystems. If you are not sure what the inode is then (click wiki details)

6. How to list only the local file system?

# df -l

Note: Using the'-l' option will filter the entire network/remote based file system and list only the local-based file system.

7. How to list the file system usage in MB (MegaByte)?

# df -m

df command in megabytesNote: Using the '-m' option we can get the output of all the file systems disk space usage in MB (megabytes).

8. How to check the file system type?

# df -T

df command to check file system typeNote: Using the'-T' option we can get a list of file system types. You can see the types of file systems in the above example's 2nd column "TYPE" as "ext4,tmpfs,ext2".

9. How to check the disk space details of a specific file system type?

# df -t ext4

df command to check a particular file system typeNote: Using the'-t' option we can filter the output of a specific file system. In this example, I have used the "ext4" file system. You can check it accordingly.

10. How to exclude a particular file system type?

# df -x tmpfs

df command to exclude a file system typeNote: Using the'-x' option, we can exclude any particular type of file system from the output list. In this example, I have excluded "tmpfs" file system type from the output. The output can be compared with the previous example. Excludes and is without the exclusion of the tmpfs filesystem.

11. How to customize the output with certain columns?

# df -h / --output=size,used




Size Used
158G 137G

Note: Using '--output[=FIELD_LIST]'with df command you can customize your output with certain fields/columns. Check out the example I used here.

# df --help or man help

Note: For any help related to the 'df' command you can use the above commands.

I hope this article will help you to understand 'df' commands with examples. Drop me your feedback/comments. If you like this article, kindly share it  and it may help others as well.

Thank you!

Support My Work

Thank you for your support and for being a part of my journey, I would be very grateful if you could consider buying me a coffee. The contributions you make will help me to continue to produce quality content and enhance my readers' experience.

Buy Me A Coffee

Thank you for your endless support!


3 replies on “11 'df' command to check disk space in Linux with examples”

Leave a Reply

Your email address will not be published.