How to identify files that are taking most hard disk/ssd space in Mac OS X

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.

  1. Open terminal app inScreen Shot 2016-08-02 at 6.34.37 PM.png
  2. In the users home directory type in
  3. du -d1 -h | grep [0-9]G | sort -n
  4. It will look like Screen Shot 2016-08-02 at 6.39.34 PM.png
  5. The results will appear some thing like..
  6. Screen Shot 2016-08-02 at 6.40.23 PM.png
  7. For going to next level type in
  8. du -d2 -h | grep [0-9]G | sort -nScreen Shot 2016-08-02 at 6.42.47 PM.png
  9. Expansion
    1. du – Disk usage
      1. Option -d depth level
      2. -h Human format like M G k
    2. grep find only the lines with the number followed by G, as I am interested only things that are more than a Gig
    3. Sort it by number
  10. Instead of user home, if this is needed in for all disks go to the directory
  11. $ cd /volumes
  12. Screen Shot 2016-08-02 at 6.47.31 PM.png
  13. Type in the same command with say 3 levels..
  14. $du -d3 -h | grep [0-9]G | sort -n
  15. It could take quite a while, so output the content to text file
    1. $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

 

Leave a comment