10 useful Terminal commands for Mac

In this piece, we’ll show you ten simple commands you can perform with Terminal that could be of use to you now or in the future.

Mac's Terminal app icon

Although Terminal, which is a command line interface (CLI), is powerful and often times even more powerful than a graphical user interface (GUI), it’s often under-used because either people don’t take the time to learn commands, or they are too afraid to dabble in commands because one typo and you could mess something in your system up.

Fortunately, not all commands are scary. Here are ten you will love using.

1. Check server response

Ping is probably one of the more useful Terminal commands that an everyday Mac user might actually use. This command lets you check the response of a domain or IP address, such as “www.google.com” and see how quickly it takes for the server to respond.

To perform a Ping command, you’ll enter the following in Terminal:

ping www.google.com

Note that you can replace the URL with any website URL you want to or use an IP address instead.

2. Disable screenshot shadows

You can easily toggle off screenshot shadows when you take a screenshot of a specific window on your Mac by using the following command:

defaults write com.apple.screencapture disable-shadow -bool TRUE

What this command does is it changes the boolean variable related to disabling drop shadows from the screen capture configuration file on your Mac from false to true so that drop shadows no longer appear.

After the following command, you’ll use this one to save your changes:

killall SystemUIServer

This will restart critical services on your Mac to save your changes. If you ever want to re-enable drop shadows in your screenshots, you can perform the above commands again, except you’ll replace “TRUE” with “FALSE” instead.

3. Show hidden files in Finder

Terminal also provides you with an easy way to show all hidden files in Finder. It’s done with the following command:

defaults write com.apple.finder AppleShowAllFiles -bool TRUE

After making this change, you’ll have to restart Finder, which can be done with the following command:

killall Finder

Now, when using Finder to search for files, even files that were normally hidden to protect you from making unintentional changes that could potentially damage your system will be displayed.

You can also easily hide hidden files once again by repeating the above commands, except replacing “TRUE” with “FALSE” instead.

4. Make your Mac say anything you want

You can also use Terminal to have your Mac say anything you want. If you want your Mac to say something out loud, you can use the “say” command, followed by whatever it is you want your Mac to say. Here’s an example:

say "Hi iDownloadBlog, Terminal says hello."

In this example, your Mac will say exactly what is in the quotes using the default system voice.

5. Keep your Mac from falling asleep

Terminal comes with a way to keep your Mac from falling asleep, dimming the display, or showing the screensaver. Simply use the following command:

caffeinate

With this command having been used, your Mac will act like it just drank a venti-sized coffee at Starbucks. You can also set time periods up so the command is only active for a temporary period of time. To do this, add the “-t” flag, followed by the number of seconds you want the feature to be enabled for, like this:

caffeinate -t 150000

In this example, our Mac would stay awake for 150,000 seconds, and then after that time period, the command would be auto-disabled. You can also press Control + C to end the command early at any time.

6. View and clear your Terminal command history

If you ever want to see what Terminal commands you’ve entered in the past, fortunately, Terminal keeps a history, and you can always check back with the following command:

history

Once you enter it, you’ll see all of the commands you’ve used or anyone else using your Mac may have used. It also makes it easy to copy and paste long commands you may have entered previously that you don’t feel like typing out all over again.

If you ever wanted to delete your command history from Terminal, you could just use the following command instead:

history -c

After entering this command, your history will be deleted, and no one will be able to pull up your command line history to see what commands you’ve used.

7. Stress test your Mac

If you suspect your Mac’s fans aren’t working right or that your system can’t keep up with demand like it should, you can stress test your processor using Terminal with the following command:

yes > /dev/null &

If you have a multi-core Mac, you’ll need to type the command several times over to match the amount of cores you have before you press return. For example, if you have four cores, then you’ll type the command 4 times in a row before pressing return, like so:

yes > /dev/null & yes > /dev/null & yes > /dev/null & yes /dev/null &

You can launch Activity Monitor on your Mac as a bonus to watch your CPU start to crank up. You can end the stress test at any time with the following command:

killall yes

If you suspect you have a faulty fan, this is a good time to listen for grinding. Moreover, it can be used to see if your process is choking too early when it should be able to handle more of a load.

8. Enable an iOS-like power chime when connected to power

Although your Mac is usually quiet when you plug a power source into it, your iOS devices all make a chime noise when you plug them in to indicate that they’re charging. With Terminal, it’s possible to enable this feature on your Mac as well with the following command:

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

Now, after tapping the return key, the chime will be enabled. You can also disable the chirp at any time with the following command:

defaults write com.apple.PowerChime ChimeOnAllHardware -bool FALSE; killall PowerChime

It’s a nice little audible sound to hear when you know the power connection is connected, but it really comes down to the opinion on whether or not to enable it.

9. Check for macOS updates more often

Your Mac is configured out of the box to check for updates for macOS and your Mac App Store apps on a weekly basis, but you can change that with Terminal. For example, if you want your Mac to check for updates daily instead, enter the following command:

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

You can change the integer to any amount you want – the number represents the amount of days your Mac will wait to check for updates, so if you wanted to return to the default weekly check, you’d use the following command:

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 7

Now, you can notified of your important app updates and macOS updates much more frequently than before.

10. Set your Mac’s screensaver as the wallpaper

macOS Sonoma lets you use a screen saver as a wallpaper. But if you’re on an old version of macOS, you can use Terminal to set your Mac’s current screen saver as wallpaper using the following fun and quirky command:

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

This will make your current screensaver the desktop wallpaper for as long as the command is running. If you close the Terminal app or use the Control + C shortcut, then the wallpaper will return to normal.

More Terminal tips: