Top 10 du commands in Linux

Top 10 du commands in Linux

Here are my top 10 du commands with examples:

Disk usage for all files in dir

This is the most basic usage of the du command:

du /path/to/folder

Human Readable format

By default du command prints size in Disk Blocks, to use human-readable format (KB, MB, GB, etc.) use the -h or –human-readable argument.

du -h /path/to/folder

Total size of folder

Use -s or –summarize to display only a total for each argument:

du -sh /path/to/folder

No disk usage for subfolders

print the total for a directory

du --max-depth 1


du -d 1

Sort by modification date

Show time of the last modification of any file in the directory, or any of its subdirectories

du -ha --time /path/to/folder

Sort by size

du -d 1 | sort -n -r

Top 5 files/folders by disk size

du -a /path/to/folder | sort -n -r | head -n 5

Top 5 files by disk size

find /path/to/folder -type f -printf "%s %p\n" | sort -rn | head -n 5

Exclude .txt files

du -ah --exclude="*.txt" /path/to/folder
Written by
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.