Directory and sub directory sizes and disk usage

Although this belongs to the Linux Command Cheat Sheet, this post is here to list all the Directory / Sub Directory and Disk drive usage

To begin with, if it is disk space you are looking for information about, the following command should display the useful disk usage information

df -h

If you want to know the size of all sub directories in a directory

Move to the directory containing the sub directories (if root, can take a long time)

du -sh *

Now, if you want to know all the directories above a certain size, in this case that measure in GBs, here is how you do it

du -h <dir> | grep '[0-9\.]\+G'

If the above lists directories not within the gigbytes domain, you can use the following instead

du -h <dir> | grep '^\s*[0-9\.]\+G'

Leave a Reply

Your email address will not be published. Required fields are marked *