The easiest way is using an application like Onyx.
You can check the amount of space taken by the files using du.
$ du -ch /path # du -ch /path
Before using any deletion command you can check with ls what exactly is going to be deleted.
$ ls /path # ls /path
When using rm enable verbose mode (-v). Don’t delete the root folders, just the files contained in them. If you have a trailing /** it will ensure you don’t have any mishaps.
$ rm -rfv /path/** # rm -rfc /path/**
As with everything related to deleting files. Be careful.
User & App Caches
[Logged user caches] $ du -ch ~/Library/Caches/ $ du -ch~/Library/Logs/ [All users caches, requires sudo] # du -ch /Users/*/Library/Caches/ # du -ch /Users/*/Library/Logs/
[Current user caches] $ rm -rfv ~/Library/Caches/** $ rm -rfv ~/Library/Logs/** [All users caches, requires sudo] # rm -rfv /Users/*/Library/Caches/** # rm -rfv /Users/*/Library/Logs/**
Check also your home folder for hidden configuration files and folders. This tends to be filled with quite a lot of old stuff.
$ ls -la ~
On shared systems deleting trashes might be of help.
You will be emptying other people’s trash. Ask for permission!
[Current user trash] $ du -ch ~/.Trash/ [All users trash] # du -ch /Users/*/.Trash/
[Current user trash] $ rm -rfv ~/.Trash/** [All users trash] # rm -rfv /Users/*/.Trash/**
# du -ch /Library/Caches
# rm -rfv /Library/Caches/**
Manually deleting these folders isn’t recommended. Although I haven’t checked in detail if there are any exceptions.
macOS will clean the folders during boot. Just restart the system.
If folders aren’t cleared, boot in Safe Mode and then restart again.
In this location sleep images used to be stored. They can be quite bulky and can be deleted.
Usually located in /tmp, but you can also use the system variable $TMPDIR.
/tmp/ can be cleared safely.By definition, anything stored in that folder will be deleted sooner or later anyway.
These would have already been deleted by deleting the applications caches earlier. They are listed here for completion.
$ du -ch ~/Library/Caches/com.apple.Safari/Cache.db # du -ch /Users/*/Library/Caches/com.apple.Safari/Cache.db
$ rm -rfv ~/Library/Caches/com.apple.Safari/Cache.db # rm -rfv /Users/*/Library/Caches/com.apple.Safari/Cache.db
Browser Caches (Chrome)
~/Library/Application Support/Google/Chrome/Default/Application Cache/
$ du -ch "~/Library/Caches/Google/Chrome/" "~/Library/Application Support/Google/Chrome/Default/Application Cache/" # du -ch "/Users/*/Library/Caches/Google/Chrome/" "/Users/*/Library/Application Support/Google/Chrome/Default/Application Cache/"
$ rm -rfv "~/Library/Caches/Google/Chrome/" "~/Library/Application Support/Google/Chrome/Default/Application Cache/" # rm -rfv "/Users/*/Library/Caches/Google/Chrome/" "/Users/*/Library/Application Support/Google/Chrome/Default/Application Cache/"
Browser Caches (Firefox)
$ du -ch ~/Library/Caches/Firefox/Profiles # du -ch /Users/*/Library/Caches/Firefox/Profiles
$ rm -rfv ~/Library/Caches/Firefox/Profiles # rm -rfv /Users/*/Library/Caches/Firefox/Profiles
$ sudo dscacheutil -flushcache ; sudo killall -HUP mDNSResponder # dscacheutil -flushcache ; killall -HUP mDNSResponder