Is your Mac feeling sluggish, even after closing unused apps? Terminal might be the secret weapon you’re overlooking. With a few powerful commands, you can clean up system junk, optimize memory, and disable resource-hogging effects—no third-party software required.
This guide walks you through practical Terminal commands that directly enhance your Mac’s performance. Whether you’re a tech-savvy user or a curious beginner, you’ll learn how to speed things up safely and effectively.
Step-by-Step: Terminal Commands to Boost Mac Performance
1. Open Terminal
- Go to Applications > Utilities > Terminal or press
Command + Space
, type “Terminal,” and hitReturn
.
2. Purge Inactive Memory
- Type:
sudo purge
- Press
Return
and enter your admin password. - This frees up RAM that’s being held by inactive apps. Expect a short lag as the system clears memory.
3. Clear DNS Cache
- Type:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- Helps with slow internet response times.
- No output is expected, but it runs silently in the background.
4. Delete System Logs
- Type:
sudo rm -rf /private/var/log/*
- Use with caution. Removes old log files that can accumulate over time.
- May prompt for admin password.
5. Disable Window Animations
- Type:
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
- Follow with:
killall Finder
- Speeds up window open/close transitions.
6. Reduce Transparency and Motion (via Terminal)
- Type:
defaults write com.apple.universalaccess reduceTransparency -bool true
- And:
defaults write com.apple.universalaccess reduceMotion -bool true
- Restart your Mac or log out to apply changes.
7. Clear User and System Caches
- Type:
sudo rm -rf ~/Library/Caches/*
- Then:
sudo rm -rf /Library/Caches/*
- Be cautious—this deletes temporary files and may log you out from some apps.
8. Reindex Spotlight
- Type:
sudo mdutil -E /
- Useful if Spotlight search is slow or laggy.
- Rebuilding the index can take some time but boosts system responsiveness.
Pro Tips & Workflow Improvements
- Automate cleanup with a shell script if you regularly use these commands.
- Use
top
orhtop
to monitor what’s consuming memory and CPU in real-time. - Create aliases in your
~/.zshrc
or~/.bash_profile
to reuse commands quickly. - Run periodic maintenance using
periodic daily
,periodic weekly
, andperiodic monthly
. - Use
brew doctor
(if Homebrew is installed) to find system misconfigurations.
Advanced Use Case: One-Click Maintenance Script
Create a file named speedup.sh
:
#!/bin/bash
sudo purge
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo rm -rf /private/var/log/*
sudo rm -rf ~/Library/Caches/*
sudo rm -rf /Library/Caches/*
Make it executable:
chmod +x speedup.sh
Run it with:
./speedup.sh
Troubleshooting & Common Mistakes
- Command not found? Check your spelling or macOS version—some commands may differ.
- Permission denied? Always use
sudo
where required. - Accidental deletions? Avoid removing files outside of cache/log folders.
- No noticeable speedup? Some effects are subtle; others require a reboot.
- Mac won’t boot? Never modify
/System
or root-level files unless you’re sure.
Conclusion
Using Terminal commands is a powerful way to regain speed and efficiency on your Mac without installing anything new. After going through these steps, you should notice faster app launches, reduced lag, and smoother performance.
Keep practicing these techniques, and explore Terminal’s potential further by learning automation and script scheduling. You might also enjoy our next guide: “How to Use Automator to Schedule Mac Maintenance Tasks.”