How to check disk usage per file/directory on linux

Do you need a hand to check disk usage in a linux terminal? This ad-free guide is for you!

a year ago   •   2 min read

By aquasp

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.


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).


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:

Spread the word

Keep reading