+161 votes
297 views
in Programming by (1.1k points) | 297 views

Please log in or register to answer this question.

1 Answer

+156 votes

This single command is all you need for this task, but there’s an even shorter one that works well too. You can use the built in -t or –threshold option of the du command like this:

du -h -d 1 -t 1G /

It will display first level directories larger than 1GB within the root / path, just like the first command. If you want it to display all directories, not just first level, just leave out the -d 1 option.

You can sort the results from largest to smallest by piping in the sort command

du -h -d 1 -t 1G / | sort -hr

by (72 points)