If you ever wanted to see how much free disk you have on Linux, there are effortless ways to do so.
Sort disk by biggest files/folders
Du can be used to show you the biggest files in a folder. Here is an example:
du -shc * | sort -rh
If you want to limit how many files do you see on output, head can be used at the end:
du -shc * | sort -rh | head -10
Here is how it looks like:
Great view, isn't it? That will help you to debug big files and folder quickly.
General Disk usage
You can use the following command to check the disk usage:
df -h
This will return the usage for each partition. Usually, what you as the end user wants to know if how much space is being used on /. Check the last table, for "Mounted on"
In my case, for example, it appears in the middle. I'm currently using 64GB/226GB.
Inodes
Now, what if you would like to check inodes? Inodes are each file. 1 file = inode. No matter how big or how small it is, 1 file = 1 inode.
To check inodes on the current directory, one good way is with this command:
du --inodes ./ --max-depth=1
It will show you the indoes in each folder, limiting max-depth to 1. This means that the du
command will only report on the files and directories immediately within the current directory, and not any subdirectories or files within those subdirectories.
The total count will still be the same, but it won't show all the subfolders (that wouldn't help you to detect inodes).
Conclusion
That is it. I hope this was useful for you!
If you enjoyed this article, you can share it your friends or subscribe to The Self Hosting Art to keep us motivated. Thank you for reading :)You can also help with crypto:
Monero:
837X2SppmrrPkBbpsy9HQU1RFxKhsBcn6GdQv2wR5wGoiw8ctfh6Rt36xaszveZHysYA5KSDBr51y5YuQ3YCV23sJS9nhqW
BTC:
bc1qrvgz7dzzlfllulakw87vzvtf7s2u8t0sxpjehr
Litecoin:
ltc1qycz6ssg6xjxttuld6l6ulzqdr3y70rm8wv2g9p
Nano:
nano_1jmd6dg4dbem7f3wrojr7g45ioe6eb5et3iq11f8urfxe8qausxipup8bhua