Of recent, my available hard disk space keeps growing and could not figure out what’s occupying most of my space. I don’t want to install an app, when there is such easy way with the power of unix commands.
- Open terminal app in
- In the users home directory type in
- du -d1 -h | grep [0-9]G | sort -n
- It will look like
- The results will appear some thing like..
- For going to next level type in
- du -d2 -h | grep [0-9]G | sort -n
- Expansion
- du – Disk usage
- Option -d depth level
- -h Human format like M G k
- grep find only the lines with the number followed by G, as I am interested only things that are more than a Gig
- Sort it by number
- du – Disk usage
- Instead of user home, if this is needed in for all disks go to the directory
- $ cd /volumes
- Type in the same command with say 3 levels..
- $du -d3 -h | grep [0-9]G | sort -n
- It could take quite a while, so output the content to text file
-
- $du -d3 -h | grep [0-9]G | sort -n > disk_usage_aug_2_2016.txt
Using this was able to quickly find out things I don’t need and recover more than 50 Gigs my SSD and 100’s of gigs in hard disk.
Tips:
- Keep the depth 2 to 3 levels to make it easier to read the results, can always to go the directory with the most usage and do next level
- Disconnect external network drives if not needed when looking from the /volumes level, as that takes a really long time