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.

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:

Sample output

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)

Sample output

check-disk-space-in-Linux-df-command-

-m – displays disk space in MB (Megabytes)

Sample output

check-disk-space-in-Linux-df-command-

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

Sample output

check-disk-space-in-Linux-df-command-

Check disk space of a specific directory

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

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

Sample output

useradd-u-option

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 :

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

Sample output

check-disk-space-in-Linux-df-command-

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:

Sample output

check-disk-space-in-Linux-df-command-

Getting help with df commands

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

Sample output

df-man-pages

Additionally, to get help run the command

Sample output

df-man-pages

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.

By admin

Leave a Reply