I am trying to get the size of an user's folder named allysek and I am using this command du -hLlxcs allysek. I know I don't have permissions to some of the locations.

In the end, I get an output as follows,

du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-mjyger/PS-NOVA/IMR90.NOMe-seq.bam’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-mfter/PS-NOVA/IMR90.NOMe-seq.bam.bai’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-iuhgi/PS-NOVA/colon.WGBS.bam’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-kh/PS-NOVA/colon.WGBS.bam.bai’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-h/PS-NOVA/dbNOVA_135.hg19.sort.vcf’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-master/PS-NOVA/hg19_rCRSchrm.fa’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-master/PS-plot/DKO1.NOMe-seq.bam’
du: cannot access ‘/export/mite-09/bc/users/allysek/charlet/PS-tools-master/PS-plot/DKO1.NOMe-seq.bam.bai’
896M    /export/mite-09/bc/users/allysek
896M    total

So my question is, does the 896M total include sizes of items which I wasn't able to access as well?

  • 5
    Nope, it only counts the inodes it can read. – Satō Katsura Nov 4 '16 at 18:40
  • Note: although it wouldn't be a hard thing to implement, there is no way in any unix (or any non-unix) fs to track the size of the files in a directory. Any tool calculating this, has to track the whole directory structure and sum up the found file sizes. If there is no permission to do that, they won't calculate it into the sum (and, as the answers say, you get an error message). There are some pluggable filesystems (for example, reiser4), mainly in experimental phase, they could be easily extended with it, but I never heard it had been done with any of them. – peterh - Reinstate Monica Nov 4 '16 at 19:54

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
| improve this answer | |

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
| improve this answer | |

No. Compare the output of

du -shc /


sudo du -shc /
| improve this answer | |

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.