Skip to content
30 November 2026 An independent technology publication
Tutorial

Mac Terminal commands: 40 essential ones for 2027

40 essential Mac Terminal commands for 2027: files, Finder tweaks, network tests, security checks and Homebrew 5, with annotated screenshots for beginners.

Mac Terminal commands: 40 essential ones for 2027, DevQuarry featured image

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.

Mac Terminal commands: 40 essential ones for 2027, DevQuarry featured image

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, du and mdfind.
  • defaults write changes 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 curl into 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 commandWhat it does
Tabcompletes file and folder names
Up arrowrepeats the previous command
Control + Rsearches your command history
Control + Cstops the command that is running
Command + Kclears the window
man lsshows 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.

Mac Terminal commands basics: a Terminal window with the prompt, a command and its output annotated

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.

#CommandWhat it does
1pwdshows which folder you are in
2ls -lalists everything in the folder, including hidden files, with sizes and dates
3cd ~/Downloadsmoves into a folder
4open .opens the current folder in Finder
5open -a "TextEdit" notes.txtopens a file in a specific app
6mkdir -p Projects/2027/Q1creates folders, including any missing parents
7cp -R source/ backup/copies a folder and everything in it
8mv old.txt new.txtrenames or moves a file
9ditto -c -k --keepParent Folder Folder.zipcreates a zip the same way Finder does
10qlmanage -p photo.heicopens 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:

  1. cd ~/Downloads moves you there.
  2. ls -lt | head -20 lists the 20 newest files, newest first, so you can see what you still need.
  3. mkdir -p Installers creates a folder for the clutter.
  4. mv *.dmg *.pkg Installers/ moves every disk image and installer package into it in one step.
  5. open Installers shows 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.

#CommandWhat it does
11mdfind "invoice 2026"searches with Spotlight’s index, including file contents
12mdfind -name budgetfinds files by name only
13find ~/Documents -name "*.pdf" -size +50Mfinds large PDFs in Documents
14du -sh ~/Library/* 2>/dev/null \| sort -h \| tail -15lists the 15 biggest folders in your Library
15df -h /System/Volumes/Datashows free space on your data volume
Mac Terminal commands for disk space: du output sorted by size, with the largest folders annotated

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.

#CommandWhat it does
16caffeinate -dkeeps the display awake until you press Control + C
17caffeinate -t 3600keeps the Mac awake for an hour (3,600 seconds)
18pwd \| pbcopycopies the output of any command to the clipboard
19pbpaste > note.txtsaves the clipboard to a file
20say "Download finished"speaks text aloud; handy at the end of a long command
21screencapture -i ~/Desktop/shot.pngtakes 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.

#CommandWhat it does
22sw_versshows the macOS version and build
23system_profiler SPHardwareDataTypeshows model, chip, memory and serial number
24uptimeshows how long since the last restart
25top -o cpulive list of processes by CPU use (press Q to quit)
26pmset -g battbattery percentage and charging state
27softwareupdate -llists available macOS updates
Mac Terminal commands for system info: sw_vers and system_profiler output with the version and chip lines circled

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.

#CommandWhat it does
28networkQualityApple’s built-in speed test: download, upload and responsiveness
29ipconfig getifaddr en0shows your local IP address on Wi-Fi
30ping -c 4 apple.comchecks whether a site answers, four times
31dig devquarry.net +shortlooks up a domain’s IP address
32sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderclears the DNS cache when sites will not load after a change
Mac Terminal commands for network: networkQuality speed test output with download, upload and responsiveness annotated

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.

#ChangeCommandUndo
33show hidden files in Finderdefaults write com.apple.finder AppleShowAllFiles -bool true; killall Findersame with false (or press Command + Shift + . in Finder)
34save screenshots to a foldermkdir -p ~/Pictures/Screenshots; defaults write com.apple.screencapture location ~/Pictures/Screenshots; killall SystemUIServerdefaults delete com.apple.screencapture location
35make the hidden Dock appear instantlydefaults write com.apple.dock autohide-delay -float 0; killall Dockdefaults delete com.apple.dock autohide-delay; killall Dock
Mac Terminal commands with defaults write: the Finder hidden files tweak typed in Terminal, annotated with the undo command

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.

CommandWhat it does
diskutil listshows every disk and volume, including external drives
diskutil info /shows details of the startup volume, including whether it is encrypted
tmutil latestbackupshows 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.

#CommandHealthy result
36fdesetup status“FileVault is On.”
37spctl --status“assessments enabled” (Gatekeeper is on)
38csrutil status“System Integrity Protection status: enabled.”
39shasum -a 256 ~/Downloads/file.dmgprints 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:

CommandWhat it does
brew install wgetinstalls a tool
brew install --cask firefoxinstalls a Mac app
brew update && brew upgradeupdates Homebrew and everything it installed
brew cleanupremoves old versions and frees space
brew doctorchecks your setup for problems
brew info --sizesshows how much space installed packages use
brew bundle dumpwrites 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-quarantine option 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 bundle now manages Rust, uv and 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.

Mac Terminal commands cheat sheet grouped by files, system, network, security and Homebrew

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.

MessageWhat it meansWhat to do
zsh: command not foundthe tool is not installed or the name is mistypedcheck the spelling, or install it with Homebrew
Permission deniedyour account cannot read or change that filecheck the path; add sudo only if you are sure the command is safe
Operation not permittedmacOS privacy protection is blocking Terminalallow Terminal in System Settings, Privacy & Security, Full Disk Access
zsh: no matches foundzsh treated ? or * as a wildcardput the text in quotes, which matters most for URLs
a prompt that shows quote>a quote mark was never closedpress 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:

  1. Read every command before pressing Return. If you cannot tell what it does, look it up with man or search for it first.
  2. Be careful with sudo. It runs a command as the administrator, and it is the moment to slow down.
  3. Avoid encoded commands. A long run of random characters, often ending in =, is usually Base64 hiding what the command really does.
  4. Treat curl ... | sh with suspicion. Homebrew’s installer uses this pattern legitimately, which is exactly why attackers copy it. Only run it from the official site.
  5. Never paste commands from a CAPTCHA, a pop-up or a “free up space” page. Those are scams.
Mac Terminal commands safety: a suspicious pasted command beside a safe one, with the warning signs circled

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.

About the author Aradhya Chaudhary

Data Scientist | Freelancer | Speaker & Writer skilled in programming, development and building AI/ML backed systems.

More from Aradhya
Keep reading

More in Operating Systems

All of Operating Systems →