Linux df Command to Check Disk Space

Filed Under: UNIX/Linux

Periodically, you may need to monitor or check the disk space on your system to ensure that you have enough space to install software packages or save files. There are plenty of tools on the internet for checking disk space. Linux comes with its own built-in utility called df for checking the amount of disk space on your system. In this article, we look at how you can check disk space in Linux using the df command.

Check disk space using Linux df command

The df command without any options displays total blocks, used space, available disk space and mount points located on the filesystem.

$ df 

Sample output
Check Disk Space In Linux Df Command

Check disk space of all filesystems

To display disk space of all file systems, use the -a option as shown. Apart from displaying the conventional filesystems, the -a option displays dummy filesystems:

$ df -a

Sample output

df -a  Checkbytes,pace For All Filesystems

Check disk space in human readable format

AS previously seen df command displays information in bytes, which is not exactly easy to read format. You can display disk space in a human-readable format using the following options.

-h – displays disk space in GB (Gigabytes)

$ df -h

Sample output

Df H Display Disk Space In Linux In Human Readable Format

-m – displays disk space in MB (Megabytes)

$ df -m 

Sample output

df -m display disk space In Megabytes

Display the type of file system

To display the file system type of your system’s mount points, use the -T flag as shown below

$ df -T 

Sample output

df -T command

Check disk space of a specific directory

To check the disk space of a specific directory, use the syntax below:

$ df -Th /directory_name

For example, to check disk space on the /var directory , execute the command:

$ df -Th /var

Sample output

Check Disk Space On A Directory

Display a specific file system

If you wish to display a specific file system, use the -t option followed by the filesystem type.
For example, To display the ext4 filesystem , execute the command :

$ df -t  ext4

Sample output

Display Specific File System

Exclude a certain file system type from getting displayed

If, say , you want to display all file systems apart from the ext4 type , use the -x command as shown

$ df -x  ext4

Sample output

Exclude A File System From Being Displayed

Display file system inodes

To display information of the number of used inodes and their corresponding percentage in the filesystem, use the -i option as shown:

$ df -i 

Sample output

Display Inodes

Getting help with df commands

To get your way around with more command options visit the df man page as shown

$ man df 

Sample output

df man pages

Additionally, to get help run the command

$ df --help 

Sample output

df  -- Help

Conclusion

That was on an overviews of the various df command options. In this guide, we walked you through how you can check disk space in Linux. Feel free to try out the commands and leave your feedback.

Leave a Reply

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

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages