5 Terminal Commands to Clean & Speed Up Your MacBook Daily

There are certain routine habits you can do to clean your Mac device and to boost its performance.

All these can be done simply using command lines and inserting them into your Mac Terminal app.

Learning to use command lines are very useful as graphical user interface (GUI) can change when software versions get a major upgrade, however the command lines are always the same.

Search for “Terminal” and open the app to begin.

How to Clean and Speed Up macOS Using the Terminal Command line?

Here are the five (5) easy Mac terminal command lines you can use to clean and speed up your macOS device.

1. Clear up RAM memory

For every application we use and every system process that is running, they are stored in the Random Access Memory (RAM) of your MacBook.

Even when they are not active at the moment, they are still stored as inactive RAM. In short, they are still taking up space in your RAM.

Freely up these inactive RAM can smooth up your Macbook performance significantly. To do so, use this command in Terminal.

sudo purge

2. Flush DNS Cache

DNS Cache stores all the IP addresses of the websites you visited.

You may encounter 404 error code when visiting certain webpages. This may be caused by the location of the web server changes before the entry of your DNS cache updates.

Regularly flush your DNS Cache so that you always get the latest nameservers and ensure all websites you visit are working fine.

To do this, use this command in Terminal.

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder;

3. Clear user log files

macOS keeps certain logs files in their system and these background logs are mainly for crash reports and error reporting purposes.

The more you use your MacBook, the more log files you have.

Removing these logs files regularly can significantly clean up your macOS performance and free up more disk space.

To do so, use this command in Terminal.

cd ~/Library/Logs
sudo rm -rf ~/Library/Logs/*

4. Remove System Logs

Apple periodically clean this up automatically and these system log files occur from previous system upgrades and updates. However sometimes it can get really big in size, e.g. 10GB.

It is a good practice to clear them regularly. To do this, use this command in Terminal.

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

5. Restart your Mac regularly

Mac users usually do not reboot their Mac computers because it is easier to just close the laptop lid when you are using the Macbook.

However, Mac devices are computers and they need a fresh reboot and restart once a while.

As a good practice of habit, try to restart your Mac computer once a week. The entire rebooting and restarting should only take a minute or so.

To reboot, use this command in Terminal.

sudo shutdown -r now

Optional Steps

Empty your Trash regularly

Trash can contain large gigabytes of files over a period of time. Freeing up the space will increase your storage capacity, as well as reducing your system resources.

Select on the Trash icon on your Dock and click <Empty>.

Update to the latest macOS version

It is important to keep your system up-to-date with the latest version to protect your computer from vulnerbitilies as well as getting the latestest features.

Try to search for any new updates once a month. To do so, use this command in Terminal.

softwareupdate -l

Uninstall Unwanted Applications

Always check your installed application regularly and make sure you un-install those that you no longer need.

These unwanted applications take up storage space and take up system resources at times, especially those operate in the background and uses your system resources all the time.


To un-install application from your Mac computer, go to Finder and select <Applications>, right-click on the unwanted application and click <Move to Trash>.

Install CleanMyMac X


Probably the most convenient Mac cleaning tool with lots of positive reviews, CleanMyMac X is a easy & automated cleaning utility for your Mac device that helps you remove system junk and speed up your system resources.

The software looks into your system files, photos, emails, iTunes, analyze large and old files automatically and reports back to you on its suggestion. The user ultimately decides which to clean and which to retain, based on the software’s recommendations.

Leave a Comment

Your email address will not be published. Required fields are marked *