Du command gives different result for directory size


In my Linux Mint 19 system:

the sudo du -shc /home/* command output is

16K /home/lost+found
4.0K /home/partimag
59G /home/roger
59G total


the sudo du -shc /home/roger/* command gives a total of only 5.2 G

Where is the difference?


Welcome to It’s FOSS Community forum.

Ah! The things you discover when you start playing with Linux.

There is one simple explanation of this: the hidden files and folders.

When you did sudo du -shc /home/*, it showed 3 directories and their sum.

And when you did sudo du -shc /home/roger/*, it probably showed a bunch of directories and files and their sum.

The difference comes from what it sees. When you do /home/roger/, you are listing the contents of the directory first and then calculating its sum. The problem comes from the display because hidden folders won’t be shown in /home/roger/ (you can see the difference by using the ls command option -a).

Since the hidden folders of your home directory was not in the output of /home/roger/*, their directory size was not counted.

The correct way to check the directory size would be to use it like this:

sudo du -shc /home/roger

This way, you are not displaying the contents of the /home/roger directory. Your system will automatically takes into account all the files and folders (even the hidden ones).

I hope I was able to solve the mystery here :slight_smile:

And if you want some more on du command, here is an article I wrote earlier:


omit the “s” - you will get a consisent result…

it’s not rocket science…

du -hc ~/somedir 
du -hc ~

will give the same result

With du -shc - the “s” means summary… means don’t check parent folder or further down…

1 Like

You’re absolutely right, removing the “*” resolved the apparent inconsistency.

There is a hidden file, “.xsession-errors” that grows very fast, I don’t know why but I guess that is a topic for another discussion.

Thank you for your help.

1 Like

Removing the “s” did not make any difference the way I issued the command, using the correct syntax as per my response to Abhisek did the trick.
But you’re right, it’s not rocket science :blush:, thank you anyway.

Glad you figured out the mystery.

Take a look at xsession error file and see if you see some error messages repeated frequently.

1 Like