How-To

13 Cool MacOS Terminal Commands You Should Know

The MacOS Terminal is an often-neglected and overlooked feature. But there are so many cool Terminal commands you can use that makes the feature insanely useful.

If I can give one piece of advice to all macOS users, use the Terminal more. Seriously. It is an often neglected and overlooked feature of the macOS system. But there are so many cool MacOS Terminal commands you can use that make the feature insanely useful.

Trying to use it if you are a newbie can be quite intimidating. Hollywood keeps pushing the stereotype of the Terminal window being used by hacker geeks spouting techno-babble while shutting down the main power grid while under heavy gunfire by terrorists. But it can also be used for more peaceful means, such as customizing your Mac and using time-saving shortcuts.

After trying out loads of commands, here are the ones I liked the most.

13 Cool MacOS Terminal Commands To Try Out

I’ve excluded all the really geeky and techie ones. Instead, I am focusing on ones that are straightforward and useful. To open up the Terminal window, go to your Applications folder, then “Utilities.” You will then find the Terminal.

View Hidden Files & Folders

As with Windows, macOS hides all folders essential to the system’s running. By hiding them, there is no chance of you accidentally deleting a system-critical file and crashing your entire Mac.

But some files and folders do sometimes need to be seen. For example, caches and thumbnails are usually hidden on a USB stick and can take up quite a big part of the storage space. The only way to get rid of them, short of reformatting the stick, is to view the hidden files.

In a Terminal window, type :

defaults write com.apple.finder AppleShowAllFiles -bool TRUE

then type:

killall Finder

Now, you will see all of the hidden files. But be careful what you delete. If in doubt, leave it alone.

To hide them again, repeat the command but replace TRUE with FALSE.

Download Files From The Internet Without a Browser

If you need to download a file from the Internet, you don’t always need to open a browser. You can also download it through the Terminal.

We have previously mentioned Homebrew, which allows you to download software via the browser. There is also YouTube-DL, where you can download YouTube videos via the Terminal (I love YouTube-DL).

But you can also download various bits and pieces online with the direct link.  First, specify which folder you want it downloaded to. I have set it to the Downloads folder, but you can change it to whatever you want.

cd ~/Downloads/

Then to download the file, type :

curl -O [the URL of the file]

Keep Your Mac Awake

There are various apps available for disabling the sleep function on a Mac. The one I use is the highly-rated free app Amphetamine. But if you are averse to installing lots of apps, there is actually a Terminal command you can use instead. Simply type:

caffeinate

This will stop your Mac from going to sleep. When you finally want it to close its digital eyes, you can relieve its suffering by pressing the CTRL + C buttons.

Play Tetris

I absolutely love Tetris. I can spend hours playing it. So I was delighted to learn a secret Tetris game is hidden away on the Mac.

In the Terminal, type :

Emacs

Hit enter. Now tap the Fn and F10 keys together at the same time. Press the t button, then the g button.

Finally, you will see this. Choose your game, and it will start.

Make Your Mac Sound Like An iPhone When Plugged Into Juice

This is not really a useful one. But if you like the sound of your iPhone, you can now have your Mac make iOS beeps when you plug it into the power.

defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app

Tell Your MacOS To Check For Updates More Often

It’s common-sense computer security to update your Mac often. But many people frequently overlook it, and it takes forever to download critical patches and updates. If this sounds like you, you can flip the finger to your Swiss cheese brain and instead tell your Mac to check for updates more often.

To tell it to check every day, just type:

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

Change Where You Get Screenshots Sent To

In this line of work, I do a LOT of screenshots. When I bought my current Macbook a couple of years ago, it started sending all my screenshots to the desktop. It irritates the hell out of me as I like to keep a clean desktop. But there is a way to change the default screenshot location.

Just type the following, replacing /your/location/here with the path to the folder you want to change it to.

defaults write com.apple.screencapture location ~/your/location/here

then type :

killall SystemUIServer

Create a New Default Name For Screenshots

Another cool screenshot is changing the default name for a screenshot that the Mac makes.

Usually, the Mac writes it like this – Screen Shot 2018-09-11 at 20.00.46.png – but that is so unwieldy and ugly looking. But fear not. You can change it to whatever you want.

defaults write com.apple.screencapture name "New Screen Shot Name"

then type :

killall SystemUIServer

Change What Format You Make Your Screenshots

At this point, you’ve probably decided I’ve declared Holy War on screenshots. But I promise this is the last one I’ll do on it. As well as changing the default name and location, you can also specify what file format you want them in.

Usually, I do them in PNG format, but many of my clients detest PNG. Instead, they want JPG. So since they are paying my bills, they get to decide what format my images are in. You can, of course, change it to whatever you want – GIF, BMP, or, God forbid, TIFF.

defaults write com.apple.screencapture type jpg

Kill The Dashboard

When was the last time you used the Dashboard? Yup, me neither. I think there is no use for it, and Apple should scrap it. But until they do get around to making it extinct, you can disable it instead.

defaults write com.apple.dashboard mcx-disabled -boolean TRUE

then type:

killall Dock

Add a Gap Between Apps In The Dock

I really like this one because it brings a little bit of order to my Dock. It enables you to put blank spaces in the Dock to “separate” app icons and look as if they are grouped.

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'

then type:

killall Dock

View Your Entire Download History – And Wipe It

Privacy enthusiasts (and illegal downloaders) will be horrified to hear this one. Your Mac keeps meticulous records of every file you download. So the next time the Music Police knock on your front door, don’t stop protesting your innocence. Your Mac will snitch on you.

But you can get the last laugh. To view the entire list, type:

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'

To delete all the incriminating evidence, type :

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'

If you now type the first command again, the list should be blank.

Shut Down The Mac

Finally, when it’s time to go to bed, do your Mac a favor and let it go to sleep, too.

$ sudo shutdown -h now

Or if it’s the middle of the day, and you need to restart your Mac, type :

$ sudo shutdown -r now

Conclusion

Do you have any favorite Terminal commands that I haven’t covered here? Let us know in the comments.

3 Comments

3 Comments

  1. Vince

    January 24, 2020 at 8:03 am

    Would love to have a terminal hack that puts Mac mail window on the right instead of the bottom. This gives about 9 more visable email lines. If you use your email list as your to-do list like I do having the email window on the right is very useful.

  2. lloyd

    October 3, 2021 at 3:06 pm

    really commands here, thanks for sharing, one simple command that I use alot to have an over-view of the contents of a folder is “tree”

  3. Adi

    December 12, 2022 at 9:45 pm

    it says command not found in the tetris when i type Emacs

Leave a Reply

Your email address will not be published.

 

To Top