Filed under:

How to sort directories (folders) by size in Linux

Sometimes you need to find out what are the biggest directories taking up space on your hard drive.

For example, you need to find out the email accounts that are using the most space up.

To sort the directories under the home partition in descending size order ...

du --si --max-depth=1 /home/ | sort -n -r |more

du = show disk usage
-si = in human readable (aka "nice") numbers
--max-depth=1 only show this and 1 subdirectory deep

the output is then piped to sort in numeric order reversed (i.e. largest first)

the output is then piped to more so you get it page at a time.

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read