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
![Top 10 du commands in Linux du1 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du1.png?resize=736%2C227&ssl=1)
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
![Top 10 du commands in Linux du2 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du2.png?resize=736%2C227&ssl=1)
Total size of folder
Use -s or –summarize to display only a total for each argument:
du -sh /path/to/folder
![Top 10 du commands in Linux du3 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du3.png?resize=736%2C29&ssl=1)
No disk usage for subfolders
print the total for a directory
du --max-depth 1
or
du -d 1
![Top 10 du commands in Linux du4 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du4.png?resize=736%2C113&ssl=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
![Top 10 du commands in Linux du5 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du5.png?resize=736%2C176&ssl=1)
Sort by size
du -d 1 | sort -n -r
![Top 10 du commands in Linux du6 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du6.png?resize=736%2C120&ssl=1)
Top 5 files/folders by disk size
du -a /path/to/folder | sort -n -r | head -n 5
![Top 10 du commands in Linux du7 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du7.png?resize=736%2C89&ssl=1)
Top 5 files by disk size
find /path/to/folder -type f -printf "%s %p\n" | sort -rn | head -n 5
![Top 10 du commands in Linux du8 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du8.png?resize=736%2C68&ssl=1)
Exclude .txt files
du -ah --exclude="*.txt" /path/to/folder
![Top 10 du commands in Linux du9 - Top 10 du commands in Linux](https://i0.wp.com/pcx3.com/wp-content/uploads/2021/07/du9.png?resize=736%2C215&ssl=1)