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.
1 |
$ 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:
1 |
$ 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)
1 |
$ df -h |
Sample output
-m
– displays disk space in MB (Megabytes)
1 |
$ 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
1 |
$ df -T |
Sample output
Check disk space of a specific directory
To check the disk space of a specific directory, use the syntax below:
1 |
$ df -Th /directory_name |
For example, to check disk space on the /var
directory , execute the command:
1 |
$ 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 :
1 |
$ 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
1 |
$ 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:
1 |
$ 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
1 |
$ man df |
Sample output
Additionally, to get help run the command
1 |
$ 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.