UnixDroid

System · Linux command

du command in Linux

What does du do?

du shows how much space files and folders take. du -sh folder gives one human-readable total.

du [-sh] [path]

Most useful options

OptionWhat it does
-sonly the total
-hhuman-readable
--max-depth=1one level of sub-folders

du examples

$ du -sh /var/log Try it ›

size of the log folder

$ du -h --max-depth=1 / | sort -h Try it ›

biggest top-level folders

In security work

Unexpected huge folders can be data staged by an attacker before stealing it.

Questions about du

What is the difference between df and du?

df = space on whole disks; du = space used by specific files and folders.