macOS : Removing caches and temporary files in macOS

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

List files.

[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/

Delete files.

[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!

List files

[Current user trash]
$ du -ch ~/.Trash/

[All users trash]
# du -ch /Users/*/.Trash/

Delete files.

[Current user trash]
$ rm -rfv ~/.Trash/**

[All users trash]
# rm -rfv /Users/*/.Trash/**

System Caches

List files.

# du -ch /Library/Caches

Delete files.

# 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.

Temporary files

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.

Browser Caches

These would have already been deleted by deleting the applications caches earlier. They are listed here for completion.


Listing files.

$ du -ch ~/Library/Caches/

# du -ch /Users/*/Library/Caches/

Deleting files.

$ rm -rfv ~/Library/Caches/

# rm -rfv /Users/*/Library/Caches/

Browser Caches (Chrome)

~/Library/Application Support/Google/Chrome/Default/Application Cache/

Listing files.

$ 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/"

Deleting files.

$ 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)

Listing files.

$ du -ch ~/Library/Caches/Firefox/Profiles

# du -ch /Users/*/Library/Caches/Firefox/Profiles

Deleting files.

$ rm -rfv ~/Library/Caches/Firefox/Profiles

# rm -rfv /Users/*/Library/Caches/Firefox/Profiles

DNS Caches

$ sudo dscacheutil -flushcache ; sudo killall -HUP mDNSResponder

# dscacheutil -flushcache ; killall -HUP mDNSResponder
image_printPrint this page

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.