2

In the past if I want to see the size of all folders within my current directory, I would use the following:

du -sh ./*

When I do this on my most recent distro install (Manjaro) it is returning the /bin directory as 0. There are over 3000 subdirs in /bin and when I do du -sh ./* from within bin it shows that each subdir has a size.

Does my du command only show the size of the files within the first level of each folder and not include the subdirs?

2
  • 2
    If bin is a symbolic link, the "no space used here" does make sense...
    – vonbrand
    Oct 20, 2015 at 19:42
  • Ahh, that would be it. I didnt realize it was a symbolic link. Makes sense now. So I would want to use du -shD ./* Thanks for pointing that out, can I select a comment as the answer?
    – jeff
    Oct 20, 2015 at 23:46

2 Answers 2

2

On Arch Linux and derivatives such as Manjaro, /bin is a symbolic link to /usr/bin. A symbolic link has size 0, so du /bin reports 0.

In the output of du /*, the files under /bin are accounted for under /usr, because that's where they really are — in /usr/bin.

These days, the size of disks tends to be much larger than the size of operating systems, so the classical distinction between /usr (where most application programs live) and /bin+/etc+/lib+/sbin (containing the minimum necessary to get the system started) is often considered irrelevant. This is why some distributions such as Arch have merged them and don't support separating /usr from the root partition anymore.

1

What is preventing du to output the size of the subfolders is the -s argument (short for --summarize), which will make du to only output the size of its arguments, and not include subfolders.

Try du -hc / instead.

2
  • du -hc / doesnt give me the size of the folders in the given directory, it scrolls through everything and is rather pointless unless I were to pipe it to something. Id like something that simply lists the total size of each folder in my current directory, so if im in root it would just show me how large bin, boot, dev, etc.. is. du -shc ./* also shows bin as being 0 bytes.
    – jeff
    Oct 20, 2015 at 22:44
  • du -hc / should output the size of each folder (and subfolder), unless you are using a really obscure version of du. Also, you can use du within an one-liner like this: IFS=$'\n'; for dir in $(ls); do du -sh "$dir"; done.
    – Kira
    Oct 20, 2015 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .