Alternative Folder Size Command

Sep 2025

Introduction

There are many ways to work out the size of folders, but this one that I learnt today seems to be perfect for my needs.
It is using the du (disk usage) command again, but with some different switch at the end.
You need to login as root (sudo -s) for this to work as you may end up with permission errors, depending on what folders you are searching.

Remember, this command works from the folder you are in, so if you want to look at all folders, you need to be at the root folder (cd /).
We are going to use the command du -h –max-depth=1 to show folder sizes.

du -h --max-depth=1
2.2G ./usr
28M ./etc
4.0K ./mnt
4.0K ./dev
440K ./.kube
4.0K ./media
0 ./proc
16K ./lost+found
14G ./run
536K ./tmp
12G ./opt
70M ./boot
18M ./root
0 ./sys
4.0K ./srv
788K ./home
26G ./var
52G .

Above we can see the size of each folder, and at the bottom the total size of all folders.