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.
Table of Contents
- 1 Check disk space using Linux df command
- 2 Check disk space of all filesystems
- 3 Check disk space in human readable format
- 4 Display the type of file system
- 5 Check disk space of a specific directory
- 6 Display a specific file system
- 7 Exclude a certain file system type from getting displayed
- 8 Display file system inodes
- 9 Getting help with df commands
- 10 Conclusion
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 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
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
-m
– displays disk space in MB (Megabytes)
$ df -m
Sample output
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
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
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
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
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
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
Additionally, to get help run the command
$ df --help
Sample output
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.