How to list the Sizes of Folders and Directories in Linux

Very simply, I wanted an easy way to list out the sizes of directories and all of the contents of those directories recursively.

df will show the total disk usage

ls -l will show you sizes of items in a folder.

The answer is to use the following:

du -h --max-depth=1 /path/folder/

This will list out the contents of /path/folder/ and show the total size of the folder’s contents:

 
Sample Output: 
209G    /mnt/share/data
2.4G    /mnt/share/Backups
54G     /mnt/share/Bin
4.8G    /mnt/share/Library
270G    /mnt/share/

Changing the max-depth to 2 will delve 1 more folder deep into the structure and give the sizes as well.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
1 + 29 =