macOS command-line tools you might not know about

Explore the world of macOS Terminal commands in our latest blog post. Learn how to update software, clear DNS cache, force shutdown, preview files, and even view hidden files, all from your Terminal.

· 2 min read
macOS command-line tools you might not know
macOS command-line tools you might not know

macOS is an intuitive operating system, but it also comes with a powerful Unix command line that can enhance productivity and solve common problems. Many of these commands are not well-known but can be extremely useful. In this blog post, we'll explore some of these lesser-known macOS terminal commands that can unlock enhanced productivity on your system.

Software Update

macOS has a built-in command-line utility called softwareupdate that you can use to update your Mac. This command is especially useful if you want to update your Mac remotely via SSH, or if you don't want to go through the steps to open System Preferences and perform the updates.

Here is how to use the softwareupdate command:

softwareupdate -i -a

When you run this command, the utility will check for updates, download, and install them if any updates are found.

Clear DNS Cache

Another useful command is the one used to clear the DNS cache. This can come in handy when a website has updated or changed servers, but your Mac is still navigating you to the old site. The following command will flush the DNS cache on your Mac:

sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache

Force Shutdown

If you encounter an issue where you cannot shut down your Mac, for instance, if an application or a background process is causing the shutdown to stall, you can use the following Terminal command to force a shutdown:

shutdown -r now

If the shutdown still doesn't occur, adding "sudo" in front (which will require your administrator password) will guarantee to shut down your Mac every time.

QuickLook Preview

The macOS QuickLook feature provides an easy way to view images, PDFs, and other documents in the Finder without the need to open the document's app. This feature is also available through the Terminal with the qlmanage command:

qlmanage -p ~/Desktop/text.txt

This command opens the QuickLook window with the file passed into the command, which is great for when you're using the command line to manage files.

View Hidden Files

macOS hides all folders essential to the system’s running to prevent accidental deletion. However, some files and folders may 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 following command will reveal all hidden files:

defaults write com.apple.finder AppleShowAllFiles -bool TRUE
killall Finder


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

Change Software Update Frequency

If you want your Mac to check for updates more frequently than the default setting, you can use the following command:

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

This command will instruct your Mac to check for updates every day.

Use Terminal for Fun

Finally, the Terminal can also be used for some fun commands. For instance, you can use the say command to make your Mac speak. The following command will make your Mac say a well-known phrase from Star Trek:

say -v Trinoids "We are the borg. You will be assimilated. Resistance is futile."

These are just a few examples of the numerous commands available in the Terminal. While it's not easy to remember every command, knowing some of these less common but useful commands can significantly enhance your macOS experience.