macOS disk cleanup commands#

Collection of commands to check and free disk space on macOS.

Docker#

Command Description
docker system df Show disk usage overview (images, containers, volumes, build cache)
docker system prune -a --volumes Remove all unused containers, images, build cache, and volumes

Homebrew#

Command Description
brew cleanup --dry-run Preview what can be removed (old versions, stale downloads)
brew cleanup -s Clean old versions and stale downloads (“scrub”)

System#

Find the biggest space consumers in the home directory:

Command Description
du -sh ~/Library/* 2>/dev/null | sort -rh | head -n 10 Top 10 largest items in ~/Library
du -sh ~/* ~/.* 2>/dev/null | sort -rh | head -n 15 Top 15 largest items in home (including hidden)
du -sh ~/Library/Caches Total size of the caches folder
du -sh ~/Library/"Application Support"/* 2>/dev/null | sort -rh | head -n 10 Top 10 largest apps in Application Support
du -sh ~/Library/Caches/* 2>/dev/null | sort -rh | head -n 10 Top 10 largest caches
ls -lhS ~/Downloads | head -n 10 Largest files in Downloads

du -sh displays a human-readable (-h) total (-s) per path.

Good practices#

  1. Preview before cleaning: --dry-run, -n, or a plain du scan first.
  2. Caches are safe to delete in most cases — applications regenerate them.