The Most Useful Terminal Commands Every Mac User Should Know

The Most Useful Terminal Commands Every Mac User Should Know

Terminal on your Mac can do some surprisingly useful things, such as check your internet’s speed, change which kinds of apps you see in the dock, and help you shut down your Mac at a scheduled time. There are also some features that can only be accessed using Terminal, so if you haven’t bothered using it much until now, it’s a good time to change that.

Launch an internet speed test

If you have macOS Monterey, you can check your internet speed directly from Terminal. To run upload and download speed tests simultaneously, type the following command and press enter:

networkQuality

If you want to run upload and download speed tests one at a time, use this command:

networkQuality -s

Hide inactive apps from the dock

The dock on your Mac can sometimes feel too crowded. One way to fix that is by hiding all inactive apps from the dock. You can do this with a simple Terminal command.

defaults write com.apple.dock static-only -bool true; killall Dock

To return the dock to its original state, use this command:

defaults write com.apple.dock static-only -bool false; killall Dock

Alternatively, you can reset your Mac’s dock to factory defaults, too, if you use the following command.

defaults delete com.apple.dock; killall Dock

Restart Finder

Finder is like an invincible boss from that game everyone keeps talking about. You can quit or force-quit all apps on your Mac except Finder. However, this little cheat code will help you restart Finder, which is useful when the app gets stuck.

killall Finder

You can also add an option that lets you quit the app (which means relaunch in the case of Finder) from the menu bar. Use this command to get the job done:

defaults write com.apple.Finder QuitMenuItem 1; killall Finder

This will restart Finder automatically, and if you click the Finder menu at the top of the screen, you’ll see a new option called Quit Finder.

To hide this option, use this command:

defaults write com.apple.Finder QuitMenuItem 0; killall Finder

Keep the Mac’s display awake

A simple Terminal command lets you keep your Mac’s display awake. To stop your Mac’s display from going to sleep indefinitely, open Terminal and use this command:

caffeinate

When you’re ready to allow your Mac’s screen to go to sleep as it usually does, press Control + C on the keyboard.

You can also keep the display awake for an hour by using this command:

caffeinate -u -t 3600

Feel free to change the duration at the end of this command. The value has to be in seconds, so if you want to keep the display awake for 10 minutes, you can replace the number with 600.

Schedule shutdown

You can use this command to shutdown your Mac at a scheduled time:

sudo shutdown -h +30

Here +30 means you’re scheduling a shutdown in 30 minutes. You can change the number to whatever you wish. Similarly, you can schedule a restart with this command:

sudo shutdown -r +30

Create ASCII art banners

For those feeling creative but lacking the skill to become an artist, Terminal on a Mac can create beautiful ASCII art.

banner -w 50 Lifehacker

In this command, the number after -w is the width of the ASCII art, measured in pixels, and Lifehacker is the text. You can replace these values to create your own version of this artwork.

Change the default screenshot format

macOS has a fairly robust screenshot tool that saves photos of your screen in PNG format by default. If you want to change this to JPG, paste this in Terminal:

defaults write com.apple.screencapture type JPG

You can replace JPG with PDF or TIFF in the same command to use those formats for your screenshots.

Download files without opening your browser

As long as you have a direct download link copied to your clipboard or if you’ve memorized it, you can use Terminal to download the file without using your browser at all. This is the command you need for that:

curl -O URL

Note that -O is a capital o and not zero, and that you’ll have to replace URL with the download link for this command to work.

Copy and paste files

You can use the ditto command to copy and paste files from one folder to another directly from Terminal.

ditto -V [old folder] [new folder]

Here [old folder] should be replaced with the path of the original folder and [new folder] should point to the folder where you want to paste those files.

View history of Terminal commands

If you want to check all the Terminal commands you’ve used so far, try this:

history

Comments


Leave a Reply