macOS Terminal Cheat Sheet

A reference for the macOS Terminal, the Mac-only commands (open, pbcopy, mdfind), system and defaults tools, Homebrew, core Unix commands, and keyboard shortcuts.

A reference for the macOS Terminal (zsh, the default shell). Most standard Unix commands apply; below are the macOS-specific tools plus the handy Finder shortcuts.

macOS-only commands

CommandWhat it does
open .Open the current folder in Finder
open FILEOpen a file with its default app
open -a "App" FILEOpen a file with a specific app
pbcopy < FILECopy file contents to the clipboard
pbpaste > FILEPaste the clipboard into a file
say "hello"Speak text aloud
caffeinate -dKeep the Mac awake until you quit
mdfind QUERYSpotlight search from the terminal

System & defaults

CommandWhat it does
sw_versShow the macOS version
system_profiler SPHardwareDataTypeHardware overview
diskutil listList disks and partitions
softwareupdate -lList available system updates
defaults write DOMAIN key valChange a hidden app/system preference
killall FinderRestart Finder (or Dock, SystemUIServer)

Homebrew (package manager)

CommandWhat it does
brew install PKGInstall a command-line package
brew install --cask APPInstall a GUI application
brew update && brew upgradeUpdate Homebrew and all packages
brew listList installed packages
brew doctorDiagnose common issues

Core Unix commands

CommandWhat it does
ls -lahList files with sizes, incl. hidden
cd ~/DocumentsChange directory (~ is your home)
cp -r SRC DESTCopy recursively
rm -rf DIRDelete recursively (dangerous)
grep -rin PATTERN .Search files recursively
chmod +x FILEMake a file executable

Terminal keyboard shortcuts

ShortcutAction
Ctrl+CCancel the running command
Ctrl+A / Ctrl+EJump to start / end of line
Ctrl+U / Ctrl+KDelete to start / end of line
Ctrl+RSearch command history
Cmd+KClear the Terminal window
Cmd+TOpen a new tab

Tip: drag a file from Finder into the Terminal to paste its full path, and press Tab to autocomplete file names and commands.

What this does

A macOS Terminal cheat sheet gathers the Mac-only commands (open, pbcopy, mdfind), system tools, Homebrew, and core Unix commands.

How to use it

  1. Browse by section.
  2. Find the command you need.
  3. Copy it with one tap.
  4. Run it in Terminal.

Example

open . opens the current folder in Finder.

Sources & methodology

Last updated .

Frequently asked questions

What shell does macOS use?

Modern macOS uses zsh by default. Almost all standard Unix commands apply, plus Mac-specific tools like open, pbcopy/pbpaste, and mdfind.

What is Homebrew?

Homebrew is the popular third-party package manager for macOS. Use brew install for command-line tools and brew install --cask for GUI apps.

How do I copy a file path into Terminal?

Drag the file from Finder into the Terminal window and its full path is pasted, or use Tab to autocomplete names as you type.