I'm trying to track down the biggest disk users on a disk that is getting full. I usually use the du command for this, but this time I'm getting strange inconsistent results from it that I don't understand.

I have already identified a user that is supposedly using 78GB of space:

# cd /home/userx
# du -sxk .
78066324    .

But when run du again on all the files to identify which files are the biggest, I get very different results:

# du -sxk * | sort -n
76240   RPMS
80828   save.oldcomputer
108536  docs
114472  rpmbuild
304652  chef-repo

i.e. the top five directories take up just over 500MB, and if you added up the whole lot including all the little tiny ones, it would still be less than 1GB. So where did the other 77Gb go?

  • 2
    Try something like du -sxk .[a-zA-Z0-9]* | sort -n – user4556274 Aug 12 '16 at 18:56
  • -k option means --block-size=1K, so 78066324K is about 76236M and about 74G. Sorting in reverse order could be done with -r option (if you want to get biggest first). – Konstantin Morenko Aug 12 '16 at 18:57
  • use -h (--human-readable) rather than -k to get sizes with K,M,G suffixes. – cas Aug 13 '16 at 15:53

Most probably hidden files. * doesn't include hidden files on expanding, so du won't report on them.

Try du -axkd1 . | sort -n

  • Of course! That was it exactly. I don't how I missed that. :) The version of du on the RHEL5 box doesn't have the -d or -1 flags, but running "du -axk . | sort -n" showed about 60GB of old junk in ~/.local. Thanks! – guertin Aug 12 '16 at 19:32
  • 1
    -1 is not a separate flag. The flag is -d1 for depth, which can also be substituted with --max-depth=1. So, you can also use du -axk --max-depth=1 . if your man page shows that. – Munir Aug 12 '16 at 19:36
  • 3
    @Stephan, if the file is unlinked, how would du encounter it to appear in a report? – BowlOfRed Aug 13 '16 at 0:05

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.