How can I calculate the size of a directory?

du -s directory_name

Or to get human readable output:

du -sh directory_name

The -s option means that it won't list the size for each subdirectory, only the total size.


While using a separate package such as ncdu may work well, the same comparison of many folders can be done, to some degree, by just giving du a list of folders to size up. For example to compare top-level directories on your system...

cd /    
sudo du -sh ./*

GNU du takes a -b option.

See the man page and the info page for more help:

-b, --bytes is equivalent to --apparent-size --block-size=1

Tags:

Directory