alternative_folder_size_command

This is an old revision of the document!


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 to show folder sizes. 2.2G ./usr 28M ./etc 4.0K ./mnt 4.0K ./dev 440K ./.kube 4.0K ./media du: cannot access './proc/26800/task/29483/fdinfo/795': No such file or directory du: cannot access './proc/26800/task/30452/fdinfo/795': No such file or directory du: cannot access './proc/26800/task/30715/fdinfo/795': No such file or directory du: cannot read directory './proc/26979/task/26979/net': Invalid argument du: cannot read directory './proc/26979/net': Invalid argument du: cannot read directory './proc/155758/task/155758/net': Invalid argument du: cannot read directory './proc/155758/net': Invalid argument du: cannot read directory './proc/155759/task/155759/net': Invalid argument du: cannot read directory './proc/155759/net': Invalid argument du: cannot access './proc/156569': No such file or directory du: cannot access './proc/156578/task/156578/fd/4': No such file or directory du: cannot access './proc/156578/task/156578/fdinfo/4': No such file or directory du: cannot access './proc/156578/fd/3': No such file or directory du: cannot access './proc/156578/fdinfo/3': No such file or directory 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 .

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.

alternative_folder_size_command.1757506897.txt.gz · Last modified: by walkeradmin