6

I was checking my disk usage today, and ran the following commands (using sudo so I didn't get "permission denied")

$ du -hs /home
26G     /home

$ ls -la /home
total 24
drwxr-xr-x  4 root  root   4096 Dec 27  2017 .
drwxr-xr-x 25 root  root   4096 Oct  1 17:39 ..
drwxrwxr-x  3 root  root   4096 Dec 27  2017 .ecryptfs
drwx------ 53 paper paper 12288 Oct  6 14:38 paper`

$ du -hs /home/*
13G    /paper

Why is my /home directory exactly twice the size of my user directory, which looks like the only thing in /home?

21

Try executing shopt dotglob in that same shell.

Chances are that dotglob is off, which causes * expansion (globbing) to not include files and directories the names of which begin with . (including the special directory entries . and .. which I'm fairly certain are never included in wildcard expansion; imagine the mayhem caused if rm -rf ./* expanded so as to include ./..).

Thus, when you run du -hs /home it counts everything in that directory, but du -hs /home/* expands to only du -hs /home/paper and so only the latter directory is counted.

Since presumably /home/.ecryptfs contains the encrypted data, it makes sense that it would be about the same size as the decrypted data. Therefore, the files effectively get counted twice, but only when you point du at the parent directory.

If you shopt -s dotglob to turn on the dotglob setting in that shell session, then run sudo du -hs /home/* again, you will likely see that it shows as the same size as if you run sudo du -hs /home.

Another way to demonstrate this is to put echo at the beginning of the command. So, for example, instead of du -hs /home/* you could try echo du -hs /home/* which will show how the * is expanded by the shell.


As an aside, I do recommend that you not start to habitually run everything through sudo. Use sudo when you must, but not otherwise. There should be no need, for example, to run ls -la /home as the superuser; the directory /home is likely to be world readable.

| improve this answer | |
  • 1
    +1 for explaining the answer! Sure enough, /home/.ecryptfs is the same size as /home/paper. I was using "sudo" in case the directories I wasn't allowed to see were what was taking up all that extra space - I rarely use it otherwise, and I'll remove it from the original question to not confuse others. – Nick Reed Oct 6 '18 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.