With each operating system update, our computers get further away from their earliest, text-based interfaces, when copying files and launching programs required typing out specific commands rather than double-clicking on icons. But although a lot of today’s users won’t know these command line interfaces ever existed, and others will have forgotten all about them, they’re still present in macOS and in Windows. More than that, they’re still actually useful.
In this article, I’ll look at some ways you can access and use Terminal, a throwback to the days before macOS. There are two ways of launching it:
- In Spotlight, start typing Terminal, and when Terminal.app comes up, hit return.
- In Finder, go to the Utilities folder (you’ll find that in Applications) and look for Terminal.app.
There are a variety of commands you can use in Terminal. What follows are nine commands that make it worth firing up. Simply type them in at the prompt and hit Enter to confirm. To get more information about any command, use the following syntax, replacing “command” with the name of the specific command you’re interested in (and keep the quotes):
1. Change how screenshots are saved
defaults write com.apple.screencapture name “New Screen Shot Name”
By default, screenshots use the file name format “Screen Shot [date] at [time].png” and are saved on the desktop. Using the Terminal command above, changing “New Screen Shot Name” to the file of your choice, you can change this format.
The date and time will still be included, but the “Screen Shot” part will change. It can be useful if you’re putting together a batch of screenshots for one particular purpose that you need to keep separate.
caffeinate -t <length of time>
You can always change your Mac’s power settings through the Lock Screen panel in System Settings, but using the Terminal can be quicker, especially for temporary tweaks. Use the command above to keep your system awake for the specified amount of time in seconds (so 300 would equal five minutes).
You can also use the “caffeinate” command on its own, which will put off sleep mode until the Terminal window is closed. It can be handy if you’ve got lengthy tasks or downloads on the go on your Mac and don’t want them to be interrupted.
3. Get detailed system status readings
The simple “top” command can be used as an alternative to the Activity Monitor in macOS, giving you a wealth of real-time stats about the state of your system, including how much CPU time and memory each application is using. It’s great for getting a quick, at-a-glance overview of the strain your Mac is under.
Being able to force-quit applications from the Terminal window can be useful in all kinds of troubleshooting scenarios, especially if the rest of your system has frozen. Just replace “AppName” with the name of the app to shut down, without the quotes. For example, “killall Finder” would force-quit the Finder interface.
5. Put a message on the login screen
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText “Custom Text Here”
Use the command above and replace “Custom Text Here” (while keeping the quotes) to put a message on the macOS login screen. Maybe you want to leave yourself a motivational message to start each day or maybe you want to put your email address onscreen in case your MacBook gets lost.
To remove the message, run the command again with nothing between the quotation marks.
6. Shut down or restart your Mac
sudo shutdown -h now
sudo shutdown -r now
The commands listed above will either shut down (top) or restart (bottom) your Mac, which you may find easier than going through the menus. Even better, you can add a number at the end of the statement to do a timed restart or shutdown (which is handy if you’re going to be away from your computer. For example, “sudo shutdown -r +10” will restart your computer in 10 minutes’ time.
7. Show a simple calendar
The “cal” command will bring up a basic calendar onscreen showing the current month, which can be helpful for quickly checking days and dates. The function really comes into its own when you need specific months and years — “cal 1980” will show you a calendar for 1980, for example, while “cal 1 2030” will show you a calendar for January 2030 (just use the number of the month to specify it).
softwareupdate -l
sudo softwareupdate -i -a
There are various clever Terminal commands you can use for updating the macOS operating system. The first in the list above checks for updates for macOS, while the second installs any available updates. (You can also specify specific update names instead of the “-a” flag.)
9. Change the dock spacing
defaults write com.apple.dock persistent-apps -array-add ‘{“tile-type”=”spacer-tile”;}’; killall Dock
This is a classic example of the under-the-hood tweaks that Terminal is really good at: use the syntax above, and you’ll find a blank tile is added to the dock, giving you some space between your app shortcuts.
You can drag the space around the dock and carry on adding extra ones as needed. To get rid of a separator you’ve added, right-click on it and choose Remove from Dock.
That’s it for now. If you use Terminal in other ways to make things faster or easier, let us know in the comments!