10 essential macOS terminal commands

10 essential macOS terminal commands

Vital macOS terminal commands that regular users will find handy

Seeing as you clicked on this article on essential macOS terminal commands, you likely already know about the macOS Terminal app. But, for the sake of those of you who might not, it’s Apple’s text-based or command-line interface that gives you access to the Mac operating system. IT teams and coders typically utilize the app, but that doesn’t mean that it isn’t useful to every Mac user. 

Many of the macOS terminal commands might not be as useful to regular users, but there is a handful that will come in handy. So, we gathered the ten essential macOS terminal commands that even the most casual Mac user should know.

How to use macOS terminal commands

Using macOS terminal commands isn’t as hard as it looks, though it can seem intimidating.

In the terminal window, you’ll have a command prompt where you’ll enter a command, which will usually come with the option to use “flags” or special symbols that modify the command’s behavior. These will usually come after the command itself, followed by some value, like so:

command -f value

Once a terminal command is entered, press Enter to initiate the command.

How do I pull up the macOS Terminal application?

First thing’s first: you should know how to pull up the Terminal application before you can use it. Don’t worry; you might not have noticed it before, but you don’t need to do some hocus pocus to open it, as Apple makes it readily available.

There are two different yet easy ways to access it: via Utilities and via Spotlight.

To access it through Utilities, simply open your Finder, go to Applications, then open the folder labeled Utilities. Scroll down to find Terminal and double-click it to open.

The simplest way to run the Terminal app, however, is to use Spotlight, macOS’s handy dandy search and all-around help function. (Tip: you can use it for quick conversions too!)

  • Press Command + spacebar (or tap the magnifying glass icon on the top right section of your screen).
  • In the search bar that pulls up, type terminal and press Return.

What can I do with macOS Terminal?

You can use the Terminal for virtually anything on the macOS, from accessing files and folders to changing system settings. You can even use it to remotely access other systems securely, which is why IT professionals use it.

Therefore, if you’re not familiar with the app, you must use it with caution. You could change settings on your system you don’t want modified, and if you’re not a pro, you might have a hard time fixing it or changing it back. This is one powerful app, and with great power… You know the Marvel adage.

If you want to familiarize yourself with the Terminal and get comfortable with using it, it’s a good idea to start with a few simple yet essential macOS Terminal commands that even regular users can perform without issue.

What are the most useful Terminal commands for macOS?

Below are 10 of the most essential macOS Terminal commands that are just as useful to you as they are to professionals, even if all you do on your Mac is to send emails, put together work documents, and FaceTime with loved ones.

1. Update your software

You can use the Terminal to check for new software updates as well as download and install any that are available. To do so, type command:

softwareupdate -i -a

2. Change your Mac’s sleep settings

There are two ways to change your Mac’s sleep settings: in the System Preferences and using the Terminal, which is faster. If you want your Mac to stay “awake” for a specific length of time, you can use the command:

caffeinate -t <length of time>

Specify the length of time in seconds. If you want your Mac to not go on sleep mode for 60 minutes, for example, put in 3,600 as there are 3,600 seconds in an hour. That will look like this:

caffeinate -t 3600

You can also use other flags besides -t. There’s -i to prevent your Mac from going idle, -s to keep the whole system awake, and -d to keep your display from going into sleep mode.

3. Increase Dock spacing

If you’re like me, your Dock probably looks too busy and crowded. You can use the Terminal to increase the space between apps on your dock to make it look a little neater. Simply type: 

defaults write com.apple.dock persistent-apps -array-add ‘{“tile-type”=”spacer-tile”;}’; killall Dock

Then hit Return.

If you want that space removed later on, simply right-click or Command-click on it and select Remove from Dock.

4. Change screenshot name

At default, your Mac is going to use “Screen Shot” as the default screenshot name. While there’s nothing inherently wrong with that (and it does make sense), it also means that you have to individually change every screenshot’s filename. That can get tedious and time-consuming, especially if you’re working on a project that involves a whole lot of them.

Save yourself a bit of time by changing the default screenshot name. Type:

defaults write com.apple.screencapture name “New Screen Shot Name”

Replace the text New Screen Shot Name with your preferred name, of course, still enclosed in quotes. Finish it with command:

killall SystemUIServer

5. Change screenshot format

At default, your screenshots will be in PNG format, which means that every screen capture you do on your Mac will be a PNG image unless you change it. Luckily, the Terminal comes to the rescue yet again. Simply type:

defaults write com. apple. screencapture type <format>

Replace format with your preferred image type. You can choose between JPG, GIF, TIFF and RAW, which is really cool. If JPG is your chosen format, for example, it should look like this:

defaults write com. apple. screencapture type JPG

6. Compress and password-protect a folder

If you want to compress a folder and limit its access, the Terminal can help you as well. The first thing you need to do is change the directory to your folder’s location. If your folder is on your Desktop, for example, simply type: 

cd ~/Desktop/

Then type:

zip -er <output folder name.zip> <source folder name>/

So, if you have a folder named Testing and you want to use the same name for your Zip file, you type:

zip -er Testing.zip Testing/

You’ll be prompted to enter a password, which you’ll have to do twice, pressing enter after each entry. Make sure you type it correctly, as you won’t see any characters on the screen as you type (they’re still being recorded as the password though).

7. Display your hidden files and folders

You can hide files and folders on your Mac to keep them away from prying eyes. If you want to unhide those hidden files, you can type:

defaults write com.apple.finder AppleShowAllFiles TRUE 

Press Enter then type:

killall Finder

Press Enter again.

8. Shut down or restart your Mac

If you want to shut down your Mac, you can simply type:

sudo shutdown -h now

You can also restart it by typing:

sudo shutdown -r now

9. Wipe your embarrassing download history

Your Mac keeps records of all your computer activities, including all your downloads. If you want to clear your download history – or even just view it – the Terminal app can help with that. View your downloads history by typing:

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

And, to delete all of it, whatever your reasons are, type:

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

10. Make your Mac talk

You can actually make your Mac say whatever you want, and not just for fun. To do so, type in:

say “text”

Simply replace text above with whatever you want or need your Mac to say then press Return. If you want your Mac to say, “Hello, my queen,” for example, just type:

say “Hello, my queen”

Leave a Reply

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