UX Design and Development course

Eight Terminal Utilities Every OS X Command Line User Should Know


The OS X Terminal opens up a world of powerful UNIX utilities and scripts. If you’re migrating from Linux, you’ll find many familiar commands work the way you expect. But power users often aren’t aware that OS X comes with a number of its own text-based utilities not found on any other operating system. Learning about these Mac-only programs can make you more productive on the command line and help you bridge the gap between UNIX and your Mac.


$ open /Applications/Safari.app/

pbcopy and pbpaste

$ ls ~ | pbcopy

You can easily capture the contents of a file:

$ pbcopy < blogpost.txt


Anything Spotlight can find, mdfind can find too. That includes the ability to search inside files and metadata.

$ mdfind -onlyin ~/Documents essay


Capture the contents of the screen, including the cursor, and attach the resulting image (named ‘image.png’) to a new Mail message:

$ screencapture -C -M image.png

Select a window using your mouse, then capture its contents without the window’s drop shadow and copy the image to the clipboard:

$ screencapture -c -W

Capture the screen after a delay of 10 seconds and then open the new image in Preview:

$ screencapture -T 10 -P image.png

Select a portion of the screen with your mouse, capture its contents, and save the image as a pdf:

$ screencapture -s -t pdf image.pdf


launchctl lets you interact with the OS X init script system, launchd. With launch daemons and launch agents, you can control the services that start up when you boot your computer. You can even set up scripts to run periodically or at timed intervals in the background, similar to cron jobs on Linux.

For example, if you’d like to have the Apache web server start automatically when you turn on your Mac, simply type:

$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist


Without any options, say will simply speak whatever text you give it out loud.:

$ say "Never trust a computer you can't lift."

You can also use say to speak the contents of a text file with the -f flag, and you can store the resulting audio clip with the -o flag:

$ say -f mynovel.txt -o myaudiobook.aiff


diskutil is a command line interface to the Disk Utility app that comes with OS X. It can do everything its graphical cousin can, but it also has some extra capabilities—such as filling a disk with zeroes or random data. Simply type diskutil list to see the path names of disks and removable media attached to your machine, and then point the command at the volume you want to operate on. Be careful: diskutil can permanently destroy data if it’s used incorrectly.