Page 1 of 1

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!

Linux/macOS - Shell...
Clear all

Linux/macOS - Shell - List directory sizes ...

1 Posts
1 Users
Famed Member Admin
Joined: 10 years ago
Posts: 2549
Topic starter  

How does one list all directories, and see the space each directory takes up on your disk, in a given directory?

I rarely need this, but I do find myself having to Google it each time I do ... 
So for my own reference, and maybe for others as well:

(works in a Linux Shell or macOS Terminal)

du -sh /path/to/directory/*

This will list all directory in "/path/to/directory/", with it's size.

For example:

~ $ du -sh /Users/username/*                                                                                                              12:25
 30M	/Users/username/Applications
1.3M	/Users/username/Applications (Parallels)
 24M	/Users/username/Creative Cloud Files
1.1G	/Users/username/Desktop
235G	/Users/username/Documents
 18G	/Users/username/Downloads
 12K	/Users/username/Fusion 360
129G	/Users/username/Library
144K	/Users/username/Movies
 1M	/Users/username/Music
1.3M	/Users/username/untitled folder


"du" (disk usage) command estimates the space usage. Note: only for directories you have access to!!!
The Linux Man page and Apple man page can give you more details.

The options we use here: -sh

-s, --summarize; display only a total for each argument

-h, --human-readable; print sizes in human readable format (e.g., 1K 234M 2G)

-c, --total; produce a grand total


Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).