Does 'du' command count the size of unaccessible folders?
Simply not. Look this example
du -shc *
4,0K AUDIO_TS
4,4G VIDEO_TS
4,4G total
chmod 000 * #don't use this in wrong dir!
du -shc *
du: cannot read directory 'VIDEO_TS': Permission denied
du: cannot read directory 'AUDIO_TS': Permission denied
4,0K AUDIO_TS
4,0K VIDEO_TS
8,0K total
du
is an ordinary command running with your privileges and access rights. Just like ls
. What you can see is what it can see, so it cannot count files that you cannot access.
You can tell it not to complain about files it cannot access by discarding stderr:
du -hLlxcs allysek 2>/dev/null
No. Compare the output of
du -shc /
vs
sudo du -shc /