- How to Check Disk Usage on Linux
- Check Linux Disk Usage Using the df Command
- Check Linux Disk Usage Using the du Command
- Check Linux Disk Usage Using the GUI
- Conclusion
How to Check Disk Usage on Linux
Getting the disk information is quite handy when you’re working with a Linux system, and you have several command-line tools to check it. Let’s display the disk usage information using the following pre-installed Linux utilities:
You can also get the disk usage report on your screen through the graphical user interface method, so, this article will cover both of these approaches.
Check Linux Disk Usage Using the df Command
In Linux disk free or df command tool is used to print the disk information that includes the available disk space on Linux storage.
The given syntax would be followed to utilize the df command tool to find out the disk usage on Linux:
You can access the data on the terminal by running simply df command or utilizing it with the -h parameter to display in human-readable format:
Or:
The above output fields mean:
Filesystem | Shows all the drives including, physical, virtual, partitioned, and temporary drives |
Size | Shows the filesystem’s size |
Used | Displays the size of used filesystem space |
Avail | Displays the available space on the filesystem |
Use % | Displays the used space in percentage |
Mount on | Displays the directory location where the filesystem is stored |
Execute the mentioned command to print the disk usage of the file system, even if the available and used field is 0. This could be done by passing the -a argument with the -h (which helps to display out in human-readable format):
If you also want to see the filesystem type while displaying the disk usage information, use the -T parameter with the df command; like:
To print the used and free index node (inode) against each filesystem, pass the -i argument:
Or you can use the -i argument with the -T to display the inode with the filesystem type:
To display the disk used and available for a specific filesystem’s type, the following syntax would be followed:
For example, to show only the tmpfs file type disk usage information, run the given command:
And, to show the complete data except for any specific type, the -x argument would be passed, like:
Use the –o parameter to show all the fields while displaying the disk space usage information on the Linux terminal:
You can also check the complete filesystem and disk usage information by passing the -a or –all argument with the df command tool and this will present you with the whole disk report:
To get more help regarding the Linux df command tool, you can visit the man page or pass the –help parameter:
Or:
Check Linux Disk Usage Using the du Command
Linux disk usage or du command-line tool helps to mention the disks or block usage reports in all files and directories. It also helps to identify which file or directory is consuming more space in the Linux system.
We can utilize the du command to find the disk usage information against each file and folder in the Ubuntu server:
Pass the -h argument with the du command to print the required result in human-readable format against files or directories. This will identify the disk size in kilobytes, megabytes, gigabytes etc.; run the given command to show how it works:
Run the du command with the -a parameter to display disk usage information against all files and directories:
To display the summarized disk usage information in the Linux server, use the -s parameter:
To show the disk usage information for a particular filesystem, execute the given command with the file location:
Run the mentioned command to display the disk space usage report in human-readable format against the particular directory i-e, /etc/ (this requires sudo privileges to access all of the /etc/ files):
You can also get the top 5 directories that occupy the most disk space in the Linux machine through the following command:
To get more help regarding the Linux du command tool, you can visit the man page or pass the –help parameter:
Or
Check Linux Disk Usage Using the GUI
Another way to get the disk usage report is through the GUI by typing Disks in the search box:
After opening the Disks app, you will get the drives on the Linux screen, click any of the partitions, and you will get its data report on the screen:
Conclusion
Checking the disk utilization is important as it helps to avoid space issues when installing anything. You can also clean when to figure out, which file or directory is consuming more disk space. Throughout this guide, we have mentioned the various approaches to finding disk usage in Linux servers. These approaches include the command-line tools and graphical user interface.
In the command-line tools, we have utilities like df and du that help to display the disk usage report on a Linux machine. Moreover, we have mentioned multiple arguments with these command-line tools to display output in different fields and formats.