Mac Terminal commands let you do things the Finder and System Settings hide: test your internet connection properly, keep a Mac awake during a download, show hidden files, find what is filling your disk, or check that FileVault and Gatekeeper are on. You do not need to be a programmer. Most of the useful ones are a single line you can type in a few seconds.
The 40 commands below are the ones worth knowing on macOS 26 Tahoe and macOS 27 Golden Gate, grouped by task, with annotated screenshots of what each kind of output looks like. Every command here is a standard macOS tool or comes from Homebrew’s official site. None of them is encoded, and that matters more in 2027 than it used to: fake “fix your Mac” pages that ask you to paste Terminal commands were the top Mac malware trick of 2026.

The short version
- Open Terminal from Applications, Utilities, or press Command + Space and type “Terminal”.
- macOS uses the zsh shell by default. Press Tab to complete names and Control + R to search history.
- The most useful everyday commands:
open,caffeinate,networkQuality,pbcopy,duandmdfind. defaults writechanges hidden settings; each tweak here includes the command to undo it.- Homebrew 5 is the standard way to install command-line tools; install it only from brew.sh.
- Never paste a command you cannot read, especially one that pipes
curlinto a shell from an unknown page.
Why Mac Terminal commands are worth learning in 2027
Apple has redesigned System Settings twice in four years, and every redesign moves things. Mac Terminal commands barely change. caffeinate works the same way it did in 2012, and du is older than the Mac itself. Learn a command once and it keeps working through macOS 26, macOS 27 and whatever comes next.
There is a practical reason this year too. The move away from Intel apps means many people now need to check what is installed and which chip it was built for, and Terminal answers that in seconds. Our macOS 27 Golden Gate review covers the upgrade itself; the commands here help with the housekeeping around it.
Terminal basics in two minutes
When you open Terminal, you see a prompt that ends with %. Type a command, press Return, and the output appears below. A few things make the rest of this list easier:
| Keys or command | What it does |
|---|---|
| Tab | completes file and folder names |
| Up arrow | repeats the previous command |
| Control + R | searches your command history |
| Control + C | stops the command that is running |
| Command + K | clears the window |
man ls | shows the manual for a command (press Q to quit) |
How to read a command
Most Mac Terminal commands follow the same shape: the command name, then options that start with a dash, then the thing to act on. In ls -la ~/Downloads, ls is the command, -la combines two options (-l for the long format and -a for hidden files), and ~/Downloads is the folder to list. Options are case sensitive, so -R and -r can mean different things.
Spaces separate the parts, which is why a file called My Notes.txt needs quotes ("My Notes.txt") or a backslash before the space (My\ Notes.txt). Tab completion adds the backslash for you, which is one more reason to use it.

Paths starting with ~ mean your home folder. To use a file path without typing it, drag the file from Finder into the Terminal window, and its full path appears at the cursor.
Terminal settings worth changing
Open Terminal, then Settings, then Profiles. Picking a profile such as Pro or Clear Dark and setting it as the default makes long output easier to read, and the Text tab lets you raise the font size. In the Keyboard tab, ticking Use Option as Meta key lets you jump a word at a time with Option + left or right arrow, which saves a lot of backspacing when you mistype a long path.
Files and folders
The first ten Mac Terminal commands cover moving around and handling files, the jobs you would otherwise do in Finder.
| # | Command | What it does |
|---|---|---|
| 1 | pwd | shows which folder you are in |
| 2 | ls -la | lists everything in the folder, including hidden files, with sizes and dates |
| 3 | cd ~/Downloads | moves into a folder |
| 4 | open . | opens the current folder in Finder |
| 5 | open -a "TextEdit" notes.txt | opens a file in a specific app |
| 6 | mkdir -p Projects/2027/Q1 | creates folders, including any missing parents |
| 7 | cp -R source/ backup/ | copies a folder and everything in it |
| 8 | mv old.txt new.txt | renames or moves a file |
| 9 | ditto -c -k --keepParent Folder Folder.zip | creates a zip the same way Finder does |
| 10 | qlmanage -p photo.heic | opens a Quick Look preview from Terminal |
A word on rm: it deletes files immediately, without the Bin. Use it only when you are sure, and avoid rm -rf with wildcards until you are comfortable. Finder’s Bin is safer for anything you might want back.
A worked example: tidying Downloads
Here is how a few of these Mac Terminal commands work together. Say your Downloads folder is full of old installers:
cd ~/Downloadsmoves you there.ls -lt | head -20lists the 20 newest files, newest first, so you can see what you still need.mkdir -p Installerscreates a folder for the clutter.mv *.dmg *.pkg Installers/moves every disk image and installer package into it in one step.open Installersshows the result in Finder, where you can drag the folder to the Bin once you have checked it.
The * is a wildcard that matches any name. It is what makes Terminal faster than Finder for jobs like this, and it is also why commands with wildcards deserve a second look before you press Return.
Two more file commands come up often. xattr -l file.dmg shows the extended attributes on a file, including the quarantine flag macOS adds to downloads. chmod +x script.sh marks a script as runnable. You will rarely need either until a guide tells you to, and now you will know what they do.
Finding things and checking space
Search and disk space are where Mac Terminal commands beat the Finder most clearly, because they show sizes and matches the Finder hides.
| # | Command | What it does |
|---|---|---|
| 11 | mdfind "invoice 2026" | searches with Spotlight’s index, including file contents |
| 12 | mdfind -name budget | finds files by name only |
| 13 | find ~/Documents -name "*.pdf" -size +50M | finds large PDFs in Documents |
| 14 | du -sh ~/Library/* 2>/dev/null \| sort -h \| tail -15 | lists the 15 biggest folders in your Library |
| 15 | df -h /System/Volumes/Data | shows free space on your data volume |

Command 14 is the fastest way to find out why your disk is full. Our System Data on Mac guide explains what to do with the folders it shows.
mdfind or find?
Both search for files, and they work in different ways. mdfind asks Spotlight’s index, so it returns results almost instantly and can search inside documents. find walks through every folder one by one, which is slower but catches files Spotlight skips, such as anything inside hidden folders or on drives that are not indexed. Add -onlyin ~/Documents to mdfind to limit where it looks.
If mdfind returns nothing for a file you know exists, check indexing with mdutil -s /. It should say “Indexing enabled.” If it does not, Spotlight is switched off for that volume, which also explains a Spotlight search bar that finds nothing.
Everyday power tools
These are the Mac Terminal commands people keep coming back to once they know them, because each one replaces a third-party utility.
| # | Command | What it does |
|---|---|---|
| 16 | caffeinate -d | keeps the display awake until you press Control + C |
| 17 | caffeinate -t 3600 | keeps the Mac awake for an hour (3,600 seconds) |
| 18 | pwd \| pbcopy | copies the output of any command to the clipboard |
| 19 | pbpaste > note.txt | saves the clipboard to a file |
| 20 | say "Download finished" | speaks text aloud; handy at the end of a long command |
| 21 | screencapture -i ~/Desktop/shot.png | takes an interactive screenshot from Terminal |
A common pattern combines two of them: run a long job, then announce when it is done, for example softwareupdate -l; say "Check complete".
caffeinate is even more useful attached to another command. caffeinate -i brew upgrade keeps the Mac from sleeping only for as long as the upgrade runs, then lets it sleep normally. That beats changing your energy settings and forgetting to change them back.
The clipboard pair saves retyping too. cat ~/.ssh/id_ed25519.pub | pbcopy copies your public SSH key so you can paste it into GitHub, and pbpaste | wc -w counts the words in whatever you last copied. The | symbol, called a pipe, sends the output of one command into the next, and it is the reason small Mac Terminal commands combine into useful ones.
System information
These Mac Terminal commands answer the questions support staff ask first: which macOS version, which chip, how much memory, and when the Mac last restarted.
| # | Command | What it does |
|---|---|---|
| 22 | sw_vers | shows the macOS version and build |
| 23 | system_profiler SPHardwareDataType | shows model, chip, memory and serial number |
| 24 | uptime | shows how long since the last restart |
| 25 | top -o cpu | live list of processes by CPU use (press Q to quit) |
| 26 | pmset -g batt | battery percentage and charging state |
| 27 | softwareupdate -l | lists available macOS updates |

pmset -g assertions is a useful extra when a Mac will not sleep: it lists the apps currently preventing sleep.
In top, the %CPU column can go above 100 because each processor core counts as 100 per cent. A process sitting at 300 is using about three cores. If an app has frozen, killall "App Name" closes it, and killall Finder or killall Dock restarts those two when they stop responding. Both come straight back, so this is safe to try before a full restart.
Network checks
When the internet feels slow, these Mac Terminal commands tell you whether the problem is your Mac, your Wi-Fi or the wider connection.
| # | Command | What it does |
|---|---|---|
| 28 | networkQuality | Apple’s built-in speed test: download, upload and responsiveness |
| 29 | ipconfig getifaddr en0 | shows your local IP address on Wi-Fi |
| 30 | ping -c 4 apple.com | checks whether a site answers, four times |
| 31 | dig devquarry.net +short | looks up a domain’s IP address |
| 32 | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder | clears the DNS cache when sites will not load after a change |

networkQuality has been part of macOS since Monterey and measures responsiveness under load, which explains laggy video calls better than a plain speed figure. Run networkQuality -v for more detail.
Reading the networkQuality Mac results
The summary shows four lines. Uplink and downlink capacity are your upload and download speeds in megabits per second. Responsiveness is the interesting one: it measures how many round trips your connection completes per minute while it is busy, and macOS labels it Low, Medium or High. Idle latency is the delay when nothing else is happening.
A fast connection with Low responsiveness usually points to a router that queues too much traffic when it is busy, often called bufferbloat. That is why calls break up when someone else in the house starts a download. Running the test once on Wi-Fi and once on a cable tells you whether the problem is the wireless link or the line itself.
Finder and Dock tweaks with defaults write
These Mac Terminal commands use defaults write, which changes settings that have no switch in System Settings. Each one below takes effect after restarting the app named at the end, and each has an undo.
| # | Change | Command | Undo |
|---|---|---|---|
| 33 | show hidden files in Finder | defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder | same with false (or press Command + Shift + . in Finder) |
| 34 | save screenshots to a folder | mkdir -p ~/Pictures/Screenshots; defaults write com.apple.screencapture location ~/Pictures/Screenshots; killall SystemUIServer | defaults delete com.apple.screencapture location |
| 35 | make the hidden Dock appear instantly | defaults write com.apple.dock autohide-delay -float 0; killall Dock | defaults delete com.apple.dock autohide-delay; killall Dock |

Apple occasionally changes or removes these keys between macOS versions. If one does nothing on your Mac, run the undo command and move on; nothing is harmed.
Disks and backups
A few Mac Terminal commands give a faster view of your drives than Disk Utility does.
| Command | What it does |
|---|---|
diskutil list | shows every disk and volume, including external drives |
diskutil info / | shows details of the startup volume, including whether it is encrypted |
tmutil latestbackup | shows the date of your last Time Machine backup |
tmutil listlocalsnapshotdates / | lists local Time Machine snapshots stored on the Mac |
Local snapshots are one of the hidden reasons your Mac reports less free space than you expect. Our System Data on Mac guide shows how to remove old ones safely.
Security checks
These Mac Terminal commands tell you, in one line each, whether the main protections are on.
| # | Command | Healthy result |
|---|---|---|
| 36 | fdesetup status | “FileVault is On.” |
| 37 | spctl --status | “assessments enabled” (Gatekeeper is on) |
| 38 | csrutil status | “System Integrity Protection status: enabled.” |
| 39 | shasum -a 256 ~/Downloads/file.dmg | prints a checksum to compare with the one the developer publishes |
If Gatekeeper or System Integrity Protection shows as disabled and you did not turn it off yourself, treat it as a warning sign and read our Mac malware guide. Disabling either one is a common step in instructions for pirated software.
Check who made an app
Two more commands tell you whether an app comes from the developer it claims to. spctl -a -vv /Applications/Firefox.app should end with “accepted” and a line starting “source=Notarized Developer ID”, followed by the developer’s name. codesign -dv /Applications/Firefox.app prints the signing details, including the team identifier. An app that fails both checks did not come through Apple’s notarisation process, and that is worth investigating before you open it.
Homebrew: the missing package manager
Homebrew installs command-line tools and many apps with one command, and it adds hundreds of Mac Terminal commands that Apple does not ship. Get the install command only from brew.sh, which shows it on the front page. After installing, these are the commands you will use most:
| Command | What it does |
|---|---|
brew install wget | installs a tool |
brew install --cask firefox | installs a Mac app |
brew update && brew upgrade | updates Homebrew and everything it installed |
brew cleanup | removes old versions and frees space |
brew doctor | checks your setup for problems |
brew info --sizes | shows how much space installed packages use |
brew bundle dump | writes a Brewfile listing everything installed, for setting up a new Mac |
That is command 40 on the list: brew bundle dump, followed later by brew bundle on a new Mac, recreates your whole toolset in one step.
What changed in Homebrew 5
Homebrew 5.0 arrived in November 2025 and 5.1 in March 2026 (Homebrew). The changes Mac users notice:
- Downloads run in parallel by default, which makes big upgrades noticeably faster.
- Casks that fail Gatekeeper checks were scheduled to be disabled from September 2026, and the
--no-quarantineoption is deprecated. Homebrew’s maintainers said they do not want to make it easy to get around macOS security features. - Intel Macs dropped to the lowest support tier in September 2026, with no new Intel bottles built. From September 2027, Homebrew is expected to stop running on Intel Macs entirely.
brew bundlenow manages Rust,uvand Go tools as well, so one Brewfile can describe more of a development setup.
If you are on an Intel Mac, that last timeline lines up with Apple’s own; our Rosetta 2 guide covers what to do on both fronts.
A Mac Terminal commands cheat sheet
If you only keep one page of this guide, keep this one. The cheat sheet groups the most useful Mac Terminal commands by job, so you can find the right one without scrolling through every table. Save it to your desktop or print it and stick it next to your screen until the commands become habit.

Put several commands in one script
Once you have a few favourites, you can save them in a script and run them together. This small example prints a health report for your Mac: the macOS version, free space, battery state, the last backup date and whether FileVault is on.
#!/bin/zsh
sw_vers -productVersion
df -h /System/Volumes/Data | tail -1
pmset -g batt | tail -1
tmutil latestbackup
fdesetup status
Save it as mac-check.sh in your home folder, run chmod +x ~/mac-check.sh once, and from then on ~/mac-check.sh prints the whole report. Every line is a read-only command from this list, so the script changes nothing on your Mac. That is a good habit for any script you write yourself: start with commands that only look, and add ones that change things later, once you trust them.
Customise your shell
macOS has used zsh as the default shell since macOS Catalina. Its settings live in a file called .zshrc in your home folder. Two lines worth adding:
alias ll="ls -la"
alias up="brew update && brew upgrade && brew cleanup"
Save the file, then run source ~/.zshrc or open a new Terminal window. Typing up now updates every Homebrew package in one go.
When Mac Terminal commands fail
Most errors from Mac Terminal commands fall into a handful of patterns, and the message tells you which one.
| Message | What it means | What to do |
|---|---|---|
zsh: command not found | the tool is not installed or the name is mistyped | check the spelling, or install it with Homebrew |
Permission denied | your account cannot read or change that file | check the path; add sudo only if you are sure the command is safe |
Operation not permitted | macOS privacy protection is blocking Terminal | allow Terminal in System Settings, Privacy & Security, Full Disk Access |
zsh: no matches found | zsh treated ? or * as a wildcard | put the text in quotes, which matters most for URLs |
a prompt that shows quote> | a quote mark was never closed | press Control + C and type the command again |
The Operation not permitted error confuses people because it appears even with sudo. It comes from the privacy controls Apple added in macOS Mojave, which protect folders such as Mail and Messages from any app without permission, Terminal included. Grant Full Disk Access only while you need it, and switch it off afterwards.
How to run Mac Terminal commands safely
Terminal does what you tell it, with your permissions. A few rules keep that power on your side:
- Read every command before pressing Return. If you cannot tell what it does, look it up with
manor search for it first. - Be careful with
sudo. It runs a command as the administrator, and it is the moment to slow down. - Avoid encoded commands. A long run of random characters, often ending in
=, is usually Base64 hiding what the command really does. - Treat
curl ... | shwith suspicion. Homebrew’s installer uses this pattern legitimately, which is exactly why attackers copy it. Only run it from the official site. - Never paste commands from a CAPTCHA, a pop-up or a “free up space” page. Those are scams.

macOS 26.4 and later add a “Paste blocked” warning in Terminal for some dangerous pastes, but it does not catch everything. Your own judgement is still the main safeguard.
FAQ
How do I open Terminal on a Mac?
Press Command + Space, type Terminal, and press Return. It is also in Applications, then Utilities. Every one of the Mac Terminal commands in this guide runs in that app.
What shell does macOS use?
zsh, since macOS Catalina in 2019. Older Macs used bash, and most commands work the same way in both.
Are Mac Terminal commands safe for beginners?
The ones in this list are, as long as you type them as shown. Be careful with rm and sudo, and never run commands you do not understand from websites you do not trust.
How do I stop a command that is running?
Press Control + C. To close a program like top or a manual page, press Q.
How do I install Homebrew on a Mac?
Copy the install command from the front page of brew.sh, paste it into Terminal, and follow the prompts. It installs Apple’s command-line developer tools if they are missing.
Can I undo a defaults write command?
Yes. Use defaults delete with the same domain and key, or write the original value back, then restart the affected app.
What is the difference between Terminal and iTerm2?
iTerm2 is a free alternative app with extras such as split panes and better search. The commands are the same in both, because both run the same zsh shell.
Do Mac Terminal commands work on Linux?
Many do, including ls, cd, du, find and ping. Mac-only tools such as pbcopy, caffeinate, mdfind, defaults and networkQuality do not exist on Linux.
Start with five
You do not need all 40 Mac Terminal commands at once. Start with open ., caffeinate, networkQuality, du -sh and brew upgrade, and the rest will follow when you need them. Keep reading commands before you run them, and Terminal becomes one of the most useful apps on your Mac.


