Linux command: du

Quick startduCommand to calculate the space usage of files and directories

ThisduThe command will calculate the size of the entire directory:


This32The number here is a value expressed in bytes.

Rundu *The size of each file will be calculated separately:

You can setduUse the following command to display the value in megabytesdu -mUse with GigaBytesdu -g.

This-hThe option will display easy-to-understand size symbols to fit the size:

Add to-aThe option will also print the size of each file in the directory:

A convenient thing is to sort the directories by size:

du -h <directory> | sort -nr

And then piped toheadOnly the first 10 results are obtained:

ThisduThis command can be used in Linux, macOS, WSL and wherever you have a UNIX environment

Download mine for freeLinux Command Manual

More cli tutorials: