How to Check the Size of Directories

If you want to see how much data a directory contains. Here is the command you can use.

du -sh dev


746M dev

If you want to see the size of all the directory sizes…

du -sh *


4.0K	2020-07-21-06-12-49.081-VBoxSVC-7899.log
34M	apps
241M	bin
48K	CA
175M	data
4.0K	Desktop
746M	dev
86G	Documents
4.6G	Downloads
4.0K	id_rsa
4.0K	Music
4.0K	Pictures
4.0K	Public
4.0K	Templates
90M	tmp
4.0K	Videos
0	VMs

Let’s take it a little further. What if you want to check the sizes of directories up to the second level? Here is the command you can use.

sudo du -h --max-depth=2


8.0K ./.vim
4.0K ./.gnupg/private-keys-v1.d
8.0K ./.gnupg
4.0K ./Videos
620M ./dev/docker
4.0K ./Public
4.0K ./Templates
2.6G ./.local/share
2.6G ./.local
4.0K ./Pictures
19M ./.mozilla/firefox
19M ./.mozilla
8.0K ./.hplip
4.0K ./Desktop
428K ./.mozc
7.1M ./tmp/nginx-1.18.0
34M ./tmp/sublime_text_3
50M ./tmp/docker-rootless-extras
90M ./tmp
96G .

Leave a Reply

Your email address will not be published.