Linux Command - du

du - list the sizes of a folder and any subfolders

Syntax

1
du [OPTIONS] [FILE]

Options

Option Description
-a Show file sizes too
-L Follow all symlinks
-H Follow symlinks on command line
-d N Limit output to directories (and files with -a) of depth < N
-c Show grand total
-l Count sizes many times if hard linked
-s Display only a total for each argument
-x Skip directories on different filesystems
-h Sizes in human readable format (e.g., 1K 243M 2G)
-m Sizes in megabytes
-k Sizes in kilobytes (default)

Examples

List sizes of a folder and any subfolders

1
du -h /usr/local

sample ouput

1
2
3
4
5
du -h /usr/local
44.0K /usr/local/bin
4.0K /usr/local/share
4.0K /usr/local/lib
56.0K /usr/local

List sizes of all contents in a folder

1
du -ah /usr/local

sample output

1
2
3
4
5
40.0K	/usr/local/bin/envsubst
44.0K /usr/local/bin
4.0K /usr/local/share
4.0K /usr/local/lib
56.0K /usr/local

List sizes of a folder and any subfolders(deep 1)

1
du -h -d 1  /usr

sample output

1
2
3
4
5
6
7
360.0K	/usr/bin
3.3M /usr/share
6.2M /usr/lib
2.6M /usr/sbin
56.0K /usr/local
4.0K /usr/src
12.6M /usr

list sizes of .png files in current folder

1
du -ch *.png

Reference