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
| Command | What it does |
|---|---|
open . | Open the current folder in Finder |
open FILE | Open a file with its default app |
open -a "App" FILE | Open a file with a specific app |
pbcopy < FILE | Copy file contents to the clipboard |
pbpaste > FILE | Paste the clipboard into a file |
say "hello" | Speak text aloud |
caffeinate -d | Keep the Mac awake until you quit |
mdfind QUERY | Spotlight search from the terminal |
System & defaults
| Command | What it does |
|---|---|
sw_vers | Show the macOS version |
system_profiler SPHardwareDataType | Hardware overview |
diskutil list | List disks and partitions |
softwareupdate -l | List available system updates |
defaults write DOMAIN key val | Change a hidden app/system preference |
killall Finder | Restart Finder (or Dock, SystemUIServer) |
Homebrew (package manager)
| Command | What it does |
|---|---|
brew install PKG | Install a command-line package |
brew install --cask APP | Install a GUI application |
brew update && brew upgrade | Update Homebrew and all packages |
brew list | List installed packages |
brew doctor | Diagnose common issues |
Core Unix commands
| Command | What it does |
|---|---|
ls -lah | List files with sizes, incl. hidden |
cd ~/Documents | Change directory (~ is your home) |
cp -r SRC DEST | Copy recursively |
rm -rf DIR | Delete recursively (dangerous) |
grep -rin PATTERN . | Search files recursively |
chmod +x FILE | Make a file executable |
Terminal keyboard shortcuts
| Shortcut | Action |
|---|---|
| Ctrl+C | Cancel the running command |
| Ctrl+A / Ctrl+E | Jump to start / end of line |
| Ctrl+U / Ctrl+K | Delete to start / end of line |
| Ctrl+R | Search command history |
| Cmd+K | Clear the Terminal window |
| Cmd+T | Open 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
- Browse by section.
- Find the command you need.
- Copy it with one tap.
- 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.
Related tools
Linux Command Cheat Sheet
The essential Linux terminal commands on one page, files and navigation, permissions, processes, networking, and package managers. A quick reference for the bash shell.
Windows CMD Cheat Sheet
A quick reference for the Windows Command Prompt, file and folder commands, networking, disk and system tools, plus handy keyboard shortcuts.
PowerShell Cheat Sheet
A reference for Windows PowerShell, discovering cmdlets, the object pipeline, filtering and formatting, managing files, processes and services, plus variables and flow control.
IBM AS/400 (IBM i) Cheat Sheet
A reference for the IBM i (AS/400, OS/400) command line, the work-with commands, libraries and objects, spooled files and output queues, messages, and 5250 function-key shortcuts.