Tips&Tricks

How to get top 10 largest directories in the current directory

bash

Sometimes it’s not obvious, which directory is too big. To find the biggest directories in you computer, you may use graphic user interface and some of supported file managers. But what will you do when you don’t have a GUI?

And it’s not mythical situation. On the desktop you almost always know the biggest directory (~/Downloads :-)). On the remote server problem may comes suddenly. And there you haven’t graphic interface. Therefore you need to investigate it with only command line tools.

And here your recipe:

You can get top 10 directories in a human-friendly format using this command:

du -hs * | sort -rh | head -10