🚀 “My Mac Was Slower Than Ever — Until I Ran This One Terminal Command (M1/M2 Users Must Try This!)”
Here’s how a 2-minute script freed 10+ GB of junk and made my M1 MacBook Air feel brand new.

đź’» The Problem
If you’ve owned a Mac for more than a few months, you’ve probably noticed it — apps take longer to open, Safari hangs for a second too long, and that fan that never used to spin suddenly won’t stop.
Even the mighty Apple Silicon M1 or M2 chips aren’t immune to cache bloat — hidden folders full of temporary files, logs, and system junk that silently eat away your storage and speed.
I used to dig through Finder manually, deleting random cache folders. It worked… kind of. Then I found a faster, cleaner, geek-approved way — one simple Terminal script.
⚙️ The Fix: A One-Line Cache Cleanup Script
Here’s the exact script I used to clear my Mac’s system and app caches safely.
Works perfectly on macOS Monterey, Ventura, Sonoma, and newer (including M1 & M2 chips).
đź§ Step 1: Open Terminal
You’ll find it under:
Applications → Utilities → Terminal
Or hit Command + Space, type “Terminal”, and press Enter.
đź§© Step 2: Create the Script
Type this command:
nano ~/Desktop/clear_cache.sh
Then paste the script below:
#!/bin/zsh
echo "đź§ą Starting full Mac cache cleanup..."
sudo -v
echo "→ Clearing user cache..."
rm -rf ~/Library/Caches/*
echo "→ Clearing system cache..."
sudo rm -rf /Library/Caches/*
echo "→ Clearing temporary files..."
sudo rm -rf /private/var/folders/*
echo "→ Flushing DNS cache..."
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
echo "→ Clearing Safari cache (if exists)..."
rm -rf ~/Library/Safari/*
rm -rf ~/Library/Caches/com.apple.Safari/*
rm -rf ~/Library/Caches/Metadata/Safari/*
echo "→ Clearing log files..."
sudo rm -rf /private/var/log/*
sudo rm -rf ~/Library/Logs/*
echo "âś… Cache cleanup complete! Restart recommended."
Save it by pressing:
Control + O → Enter → Control + X
⚡ Step 3: Make It Executable & Run
Run these two commands:
chmod +x ~/Desktop/clear_cache.sh
sudo ~/Desktop/clear_cache.sh
Enter your Mac password (it won’t show as you type).
Now sit back — your Mac will do a deep clean of all caches, temp files, and logs.
When it’s done, restart your Mac.
đź’Ą The Result
I instantly freed over 12 GB on my M1 MacBook Air. Apps launched faster, and Safari finally stopped beach-balling. It felt like a fresh install — without reinstalling macOS.
Here’s what it cleaned:
âś… User caches
âś… System caches
âś… DNS cache
âś… App temp files
âś… Safari junk
âś… Log files
đź’ˇ Bonus Tip: Make It Permanent
Want to reuse it anytime?
Run:
sudo mv ~/Desktop/clear_cache.sh /usr/local/bin/clearcache
sudo chmod +x /usr/local/bin/clearcache
Now you can just type:
sudo clearcache
from any Terminal window, whenever your Mac feels sluggish. đź’¨
đź§ Why It Works
macOS caches improve performance — until they don’t. Over time, they pile up from app updates, web browsing, and system logs. Apple doesn’t provide a single “Clear All” button, but this script does exactly that — safely.
It doesn’t touch your personal files or system libraries — just removes old, rebuildable caches.
✨ Final Thoughts
If your Mac feels slower, don’t rush to upgrade or reset.
Try this first — it’s quick, reversible, and shockingly effective.
🔹 Took me: 2 minutes
🔹 Freed: 12 GB
🔹 Improvement: Immediate



