macOS is fortunate to have access to the huge arsenal of standard Unix tools. There are also a good number of macOS-specific command-line utilities that provide unique macOS functionality. To view the full documentation for any of these commands, run man
caffeinate - set Mac sleep behavior
Running caffeinate with no flags or arguments prevents your Mac from going to sleep as long as the command continues to run.
caffeinate -u -t
Adding the -d flag also prevents the display from going to sleep.
Specifying an existing process with -w
Passing a command with caffeinate
pbcopy, pbpaste - interact with system clipboard
pbpaste outputs the contents of the clipboard to stdout.
networkQuality - measure Internet speed
Run networkQuality to run an Internet speed test from your Mac.
Add the -v flag to view more detailed information.
Use the -i flag to run the network test on a specific network interface.
sips - image manipulation
sips -z
sips -Z
sips -c
sips -r
By default, sips will destructively overwrite the input image. Use the -o flag to specify a different output file path (which must have the same file extension as the input image).
open - open files and applications
open -a
open . opens the current directory in a new Finder window.
textutil - document file converter
textutil can convert files to and from Microsoft Word, plain text, rich text, and HTML formats.
textutil -convert html journal.doc converts journal.doc into journal.html.
The possible values for -convert are: txt, html, rtf, rtfd, doc, docx.
mdfind, mdls - search with Spotlight
mdfind
mdfind kMDItemAppStoreHasReceipt=1 finds all apps installed from the Mac App Store.
mdfind -name
The -onlyin
mdls
screencapture - take screenshots
screencapture -c takes a screenshot and copies it to the clipboard.
screencapture
Add the -T
taskpolicy - control scheduling of processes
taskpolicy -b
taskpolicy -b -p
taskpolicy -B -p
taskpolicy -s
say - text-to-speech engine
say
say -f input.txt -o output.aiff creates an audiobook from the given text file.
pmset - configure power management
pmset -g prints all available power configuration information.
pmset -g assertions displays information about power-related assertions made by other processes. This can be useful for finding a process that is preventing your Mac from going to sleep.
pmset -g thermlog displays information about any processes that have been throttled (useful when running benchmarks).
pmset displaysleepnow immediately puts the display to sleep without putting the rest of the system to sleep.
pmset sleepnow immediately puts the entire system to sleep.
networksetup - configure network settings
networksetup -listnetworkserviceorder prints a list of available network services.
networksetup -getinfo
networksetup -getdnsservers
networksetup -setairportnetwork
qlmanage - manage Quick Look
qlmanage -p
qlmanage -m prints status information about the Quick Look server process.
qlmanage -r restarts the Quick Look server process.
qlmanage -r cache resets the Quick Look thumbnail cache.
softwareupdate - manage OS updates
softwareupdate –list prints out available software updates.
sudo softwareupdate -ia installs all available updates.
softwareupdate –fetch-full-installer –full-installer-version
system_profiler - view system information
system_profiler by default prints all available system information, which is usually overwhelming.
system_profiler
system_profiler -listDataTypes lists all available sub-systems to get information from.
Some particularly useful ones:
system_profiler SPHardwareDataType prints an overview of the hardware of the current machine, including its model name and serial number.
system_profiler SPSoftwareDataType prints an overview of the software of the current machine, including the exact macOS version number.
system_profiler SPPowerDataType prints power and battery information, including the current AC wattage and battery cycle count.
system_profiler SPDeveloperToolsDataType prints the currently active version of the Xcode developer tools and SDK.