Unix heritage rules

Piping simple commands together yields great results.

sudo du -hxd 1 / | sort -hr | head -15

This is what is hard to achieve on, for example, Windows stock UI. A simple piping produces the listing of 15 most space hogging pieces of stuff you have from root on wards.

du: Estimates disk usage.
-h: Human-readable sizes (Kilos, Megs, Gigs).
-x: Stay on one filesystem only (skip mounted ones like /proc).
-d 1: Max depth 1 (only direct subdirs of /, no deeper recursion).

: Pipe output to next command.
sort -hr: Sort lines by size, human-readable, reverse (largest first).
: Pipe again.
head -15: Show only the top 15 lines.

Listing from root is not that informative, since it's the first level:

14G /
9.3G    /var
2.5G    /usr
2.1G    /home
119M    /boot
15M /opt
6.0M    /etc
188K    /tmp
100K    /root
32K /snap
16K /lost+found
4.0K    /srv
4.0K    /mnt
4.0K    /media

And if we want to get fancier, we can adjust the recursion depth, so we can drill deeper, and get to moar specific space hogs:

# This drills down 4 levels, so we do get a more detailed view
sudo du -hxd 4 / | sort -hr | head -15

The drilldown does tell more about what's the culprit:

14G /
9.3G    /var
7.7G    /var/lib
6.6G    /var/lib/postgresql/version
6.6G    /var/lib/postgresql
2.5G    /usr
2.1G    /home
2.0G    /home/user
1.8G    /usr/lib
1.4G    /home/user/application
1.3G    /var/cache/apt/archives
1.3G    /var/cache/apt
1.3G    /var/cache
1.1G    /usr/lib/modules
998M    /var/lib/something

All articles


Comments

No published comments yet.


Add a Comment

Your comment is held for review before it appears publicly.

Your email is never published or shared.

Up to 2,000 characters.

Tick the box, then click Submit right away (Google expires the check after about two minutes).