article blog.rubyonrails.ba
How to clean up temporary and unused files on macOS 02/10/2025 ~ Views: 74
Here are few steps I used to free some space on my MacOS 26.0.1 . I had to clean up temporary and unused files on macOS from the terminal. You need to be careful to not delete system-critical stuff. I got more then 25GB of free space after. Here are safe console approaches:

πŸ”Ή 1. Clear system & app caches

rm -rf ~/Library/Caches/*
sudo rm -rf /Library/Caches/*

(will remove user and system caches β€” apps may rebuild them on next launch)

πŸ”Ή 2. Remove old logs

sudo rm -rf /var/log/*
rm -rf ~/Library/Logs/*

πŸ”Ή 3. Delete temporary files

sudo rm -rf /private/var/tmp/*
sudo rm -rf /private/tmp/*

πŸ”Ή 4. Clear user Trash

rm -rf ~/.Trash/*

πŸ”Ή 5. Find big unused files (interactive cleanup)

To locate large files:

sudo du -h -d 2 / | sort -h | tail -n 20

Or for your home folder only:

du -h -d 2 ~ | sort -h | tail -n 20

πŸ”Ή 6. Clean old Xcode junk (if you do iOS/macOS dev)

Xcode eats a lot of space:

rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Developer/Xcode/Archives/*
rm -rf ~/Library/Developer/Xcode/iOS DeviceSupport/*

πŸ”Ή 7. Use built-in macOS purge command

macOS also has:

sudo purge

This frees up inactive memory (RAM swap) but not disk.

βœ… Tip: If you want a one-liner that cleans caches, logs, tmp, trash, and Xcode leftovers safely, you can run:

rm -rf ~/Library/Caches/* ~/Library/Logs/* ~/.Trash/* \
&& sudo rm -rf /Library/Caches/* /var/log/* /private/var/tmp/* /private/tmp/* \
&& rm -rf ~/Library/Developer/Xcode/DerivedData/* ~/Library/Developer/Xcode/Archives/*

⚠️ Important:

  • Always double-check before rm -rf!

  • Don’t run cleanup commands on /System or /Library beyond caches/logs.

  • After cleaning, a restart is often good.


Tags: cleanmacos macosspace macostmp macosfreespace macosssd

Back

OPEN TO HIRE
yes blog.rubyonrails.ba
Nezir Zahirovic
Ruby On Rails Full stack last 10 years.
C#, ASP.NET, JavaScript, SQL, CSS, Bootstrap 11 years.

Top articles

How to clean up temporary and unused files on macOS >>>
What's the Fucking Clean Code??? >>>
πŸ”΄ Top 20 Ruby on Rails Interview Questions and Answers fo... >>>
🧠 Top 20 JavaScript Interview Questions and Answers for 2025 >>>
🐍 Top 20 Python Interview Questions and Answers for 2025 >>>