Having 120GB SSD drive in my laptop as the only drive is a really interesting experience – now I’m finally managing my folders, removing old files, cleaning the folders and dusting all the odd corners.
While doing so, the following command gives a really nice overview which folders are occupying most space:
du -h --max-depth=1 | sort -h -r | less |
As it might look complicated for somebody who doesn’t have any linux experience, it’s quite easy to understand. All it does, is using three separate tools to present you the information which you require, piping data from one to the other.
Firstly, let’s use builtin command du, to show sizes of directories in current dir:
-h presents the information in human readable format (22G instead of 22836892). --max-depth=1 prints the total only if given directory is at max 1 level below the current one (so, we see all folders in current dir, but not their children).
Everything then is piped to sort.
Here, -h allows to sort by human readable numbers produced by previous command and -r is just reversing the sorting (showing largest folders first).
And then, output of this command is piped to less, which allows to easily browse through it, if there is more folders present in the output than lines in the terminal.