Most Mac terminal cheat sheets are Linux cheat sheets in disguise: ls, grep, chmod, top. Those commands run fine on a Mac, but they don’t manage it. Reading the hardware, erasing a disk, changing DNS, keeping a Mac mini awake and restarting a background job all go through Apple’s own tools, and none of them behaves like the Linux command you’d reach for first.
This mac terminal commands cheat sheet covers those macOS-only tools: system_profiler for hardware info, diskutil for disks and APFS, networksetup and pmset, defaults write, launchctl and mdfind. Every command below was run on macOS 27.0 on an M4 Mac mini with 24 GB in November 2026 (service names and timers adapted to that box), over SSH, so you’ll also see the errors a remote session gets that a desktop session doesn’t. The whole reference is a one-page PDF too.
Mac terminal commands cheat sheet
You’ll find the tables grouped by job, in the same order as the explained sections further down. Commands with sudo change system state and ask for an admin password; the rest run as your normal user. Disk identifiers such as disk8 and service names such as Wi-Fi are examples, so read yours from diskutil list and networksetup -listallnetworkservices before you type anything that writes.
System and hardware info
| Command | What it does |
|---|---|
sw_vers | macOS name, version and build number |
sw_vers -productVersion | Version number only, for scripts |
system_profiler SPHardwareDataType | Model, chip, cores, memory, serial number |
system_profiler SPSoftwareDataType | OS, kernel, boot volume, SIP state, uptime |
system_profiler -listDataTypes | Every report system_profiler can print |
sysctl -n machdep.cpu.brand_string | Chip name, for example Apple M4 |
sysctl -n hw.ncpu hw.memsize | Core count and RAM in bytes |
uname -m | arm64 on Apple silicon |
scutil --get ComputerName | The name shown in Sharing settings |
csrutil status | System Integrity Protection on or off |
fdesetup status | FileVault on or off |
softwareupdate -l | List available macOS and CLT updates |
Disks, APFS and snapshots
| Command | What it does |
|---|---|
diskutil list | Every disk, partition and APFS volume |
diskutil info / | Details of the volume mounted at / |
diskutil apfs list | APFS containers and the volumes inside them |
diskutil eraseDisk APFS Backup disk8 | Wipe disk8 as one GPT APFS volume |
diskutil eraseDisk ExFAT USB GPT disk8 | Wipe disk8 as exFAT for Windows and Linux |
diskutil unmountDisk disk8 | Unmount every volume on disk8 |
diskutil eject disk8 | Unmount and detach the disk |
diskutil verifyVolume /Volumes/Backup | Check a volume for errors (First Aid) |
diskutil image create blank --size 512m --volumeName Scratch --fs APFS t.dmg | Create a disk image |
diskutil image attach t.dmg | Mount a disk image (replaces hdiutil attach) |
tmutil listlocalsnapshots / | Local Time Machine snapshots |
sudo tmutil thinlocalsnapshots / 10000000000 4 | Free about 10 GB of snapshot space now |
Networking
| Command | What it does |
|---|---|
ipconfig getifaddr en0 | IPv4 address of en0 |
networksetup -listallhardwareports | Map each port to en0, en1 and so on |
networksetup -listallnetworkservices | Service names other commands expect |
networksetup -getinfo Wi-Fi | IP, subnet, router of a service |
networksetup -getdnsservers Wi-Fi | DNS servers set by hand on a service |
sudo networksetup -setdnsservers Wi-Fi 1.1.1.1 9.9.9.9 | Set DNS servers on a service |
sudo networksetup -setdnsservers Wi-Fi Empty | Go back to DHCP-provided DNS |
scutil --dns | The resolver config macOS actually uses |
sudo killall -HUP mDNSResponder | Flush the DNS cache |
route -n get default | Default gateway and interface |
lsof -nP -iTCP -sTCP:LISTEN | Which process listens on which TCP port |
Power and sleep
| Command | What it does |
|---|---|
pmset -g | Active power settings |
pmset -g custom | Saved settings per power source |
pmset -g batt | Battery percentage and power source |
pmset -g assertions | Which process is blocking sleep |
sudo pmset -c sleep 0 | Never sleep while on the charger |
sudo pmset -a displaysleep 15 | Display off after 15 minutes, all sources |
sudo pmset repeat wakeorpoweron MTWRF 08:00:00 | Wake or power on weekdays at 08:00 |
pmset -g sched | Show scheduled wake and power events |
sudo pmset repeat cancel | Remove the repeating schedule |
caffeinate -i -t 3600 | Block idle sleep for one hour |
caffeinate -d | Keep the display awake until Ctrl+C |
defaults (hidden settings)
| Command | What it does |
|---|---|
defaults domains | Every preference domain on the account |
defaults read com.apple.dock | All Dock preferences you have set |
defaults read-type com.apple.dock autohide-delay | Type of one key (boolean, integer, float) |
defaults write com.apple.finder AppleShowAllFiles -bool true | Show hidden files in Finder |
defaults write com.apple.finder ShowPathbar -bool true | Path bar at the bottom of Finder |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | No .DS_Store files on network shares |
defaults write com.apple.dock autohide-delay -float 0 | Dock appears with no delay |
defaults export com.apple.dock dock-backup.plist | Back up a whole domain |
defaults delete com.apple.dock autohide-delay | Remove a key, back to the default |
killall Dock | Restart the Dock to apply Dock keys |
launchd and launchctl
| Command | What it does |
|---|---|
launchctl list | Jobs in your context: PID, last exit status, label |
plutil -lint job.plist | Check a plist for syntax errors |
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.backup.plist | Load a LaunchDaemon |
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.backup.plist | Load a LaunchAgent (desktop session only) |
sudo launchctl print system/com.example.backup | Full state of one job |
sudo launchctl kickstart -k system/com.example.backup | Run or restart a job now |
sudo launchctl disable system/com.example.backup | Keep a job from loading at boot |
sudo launchctl print-disabled system | Jobs with an enable or disable override |
sudo launchctl bootout system/com.example.backup | Unload a LaunchDaemon |
launchctl managername | Which launchd context your shell is in |
Spotlight from the shell
| Command | What it does |
|---|---|
mdfind -name invoice 2>/dev/null | Files whose name contains invoice |
mdfind -onlyin ~/Documents "kubernetes upgrade" | Content search inside one folder |
mdfind 'kMDItemContentType == "com.adobe.pdf"' | Every PDF the index knows about |
mdls -name kMDItemContentType file.pdf | Metadata attributes of one file |
mdutil -s / | Is indexing enabled on a volume |
Desktop-session tools
| Command | What it does |
|---|---|
open . | Open the current folder in Finder |
open -a TextEdit notes.txt | Open a file with a specific app |
pbcopy < id_ed25519.pub | Copy a file to the clipboard |
pbpaste > notes.txt | Paste the clipboard into a file |
screencapture -x shot.png | Silent full-screen screenshot |
Those tables cover the daily set. Below them, each section explains the commands that trip people up, mostly because they look like a Linux tool and then behave differently, and shows what each one printed on the test Mac. For keyboard work and shell setup there are separate references, the macOS keyboard shortcuts cheat sheet and the guide to Oh My Zsh on macOS.
Hardware info lives in system_profiler
There’s no /proc/cpuinfo, no lscpu and no dmidecode on a Mac. The report you see in System Information is system_profiler, and the shell can ask it for one section at a time instead of the whole dump. That matters for speed and for scripts, because a bare system_profiler runs every report in turn and buries the line you wanted. On macOS 27 there are 51 data types to pick from, and system_profiler -listDataTypes lists them.
For a quick answer, you’ll want the version, the chip and the memory. Ask for all three at once:
sw_vers
sysctl -n machdep.cpu.brand_string hw.ncpu hw.memsize
system_profiler SPHardwareDataType
On the test Mac you get macOS 27.0, build 26A428, an Apple M4 with 10 cores and 25769803776 bytes of memory, which is 24 GB. The serial number and the two hardware IDs are blanked in the capture, since they identify the machine.

On Apple silicon the block has a Chip line where Intel Macs printed a processor name and clock speed, so a script that greps for Processor Name returns nothing on an M-series Mac. The lines you’ll usually want are, in order:
Model Identifier: Mac16,10 for this M4 Mac miniTotal Number of Cores: 10, split 4 performance and 6 efficiencyMemory: the unified memory the GPU sharesSystem Firmware Version: what a macOS update just flashed
Need one value for a script rather than a report? Use sysctl or sw_vers -productVersion, because each prints a single value with no parsing. sw_vers -productVersion printed 27.0 here, which is what an install script should compare against, and uname -m printed arm64. The software report (SPSoftwareDataType) adds the kernel (Darwin 27.0.0), the boot volume, the SIP state and the time since boot.
diskutil addresses disks by identifier
Before any disk change, run diskutil list, because macOS hands out identifiers like disk4 in the order devices appear, not by port. A USB stick that was disk4 yesterday can be disk5 after a reboot, and eraseDisk will not ask which physical drive you meant. The test Mac shows why you should read the whole list.

Each physical disk appears twice: once as the disk with its partitions, and once as a synthesized APFS container holding the volumes. Read the list in this order:
disk0: the internal SSD and its partitionsdisk3: the synthesized container on that SSD- its volumes by role: System (named InternalDisk here), Data, Preboot, Recovery, VM
- anything marked
(external, physical)and its own container
On this machine the catch is the last group. It is an EC2 Mac mini, and it boots from network storage that macOS sees as disk5 (external, physical), so the volume called Macintosh HD sits in disk6, not on the internal SSD. So diskutil list external does not hide your boot disk on every Mac. Anyone booting from a Thunderbolt SSD gets the same layout, so check the volume names and sizes against the drive you plugged in, every time.
Rather than practise on a real drive, you can rehearse an erase on a disk image, which behaves like a USB stick to diskutil. On macOS 27, hdiutil create and attach print a deprecation warning that points at diskutil image (and hdiutil detach points at diskutil eject), so create and attach the image with the new verbs:
diskutil image create blank --size 512m --volumeName Scratch --fs APFS usb-test.dmg
diskutil image attach usb-test.dmg
Attaching prints the device nodes, and the first one (/dev/disk8 here) is the whole disk you erase. Give the format first, then the volume name, then the optional partition scheme, then the identifier.
diskutil eraseDisk ExFAT USB GPT disk8
An erase unmounts the disk, writes a new GPT map and formats the single partition. Once you see Finished erase on disk8, the partition type in diskutil list disk8 changes from Apple_APFS to Microsoft Basic Data, which is how exFAT shows up. The old hdiutil attach still works, as the last command in the capture shows, but it now warns every time:

Pick exFAT when your drive also has to mount on Windows and Linux, and APFS (diskutil eraseDisk APFS Backup disk8) when it only ever meets Macs. A typo in the identifier fails safely, since disk99 returned Could not find disk for disk99, but a wrong existing number does not. Writing a bootable installer to the stick is a different job, covered in the guide to creating a bootable USB on macOS and Linux.
Disk space that df and Finder disagree about usually lives in APFS snapshots. Time Machine keeps local snapshots on the startup disk, and they count against free space until macOS thins them. To see the cycle end to end, take one, list it and thin it:
sudo tmutil localsnapshot
tmutil listlocalsnapshots /
sudo tmutil thinlocalsnapshots / 10000000000 4
For the thin, you pass the mount point, the bytes to free and an urgency from 1 to 4. On the test Mac it created one snapshot and the thin removed it straight away, because 10 GB was more than the snapshot held.
NOTE: local snapshots are considered purgeable and may be removed at any time by deleted(8).
Created local snapshot with date: 2026-10-31-210628
Snapshots for disk /:
com.apple.TimeMachine.2026-10-31-210628.local
Thinned local snapshots:
com.apple.TimeMachine.2026-10-31-210628.local
One more thing diskutil info / reveals: the root filesystem is not a normal volume. On macOS 27 it reported This disk is an APFS Volume Snapshot, with Sealed: Yes and Volume Read-Only: Yes, so nothing you do in the shell writes to /System. Your files live on the Data volume mounted at /System/Volumes/Data.
networksetup works on services, not interfaces
Linux tools take an interface name. Most networksetup commands take a network service name instead, the label you see in System Settings, such as Wi-Fi or Thunderbolt Ethernet Slot 1. Pass an interface and it refuses, with an error that does not mention services at all.
en4 is not a recognized network service.
** Error: The parameters were not valid.
Get both lists before you change anything. -listallhardwareports maps each port to its device, and -listallnetworkservices prints the names the other commands expect, with an asterisk in front of any disabled one:
networksetup -listallhardwareports
networksetup -listallnetworkservices
Don’t assume en0 is the port carrying traffic. On the test Mac the built-in Ethernet is en0 but its service is disabled (*Ethernet), and the live link is en4, named Thunderbolt Ethernet Slot 1. ipconfig getifaddr en0 printed nothing and exited 1, while route -n get default named en4 straight away. Quote service names with spaces:

Setting DNS by hand and then forgetting it is a common cause of a Mac that resolves fine at home and fails on a VPN. Set the servers, check them, then hand DNS back to DHCP with the Empty keyword:
sudo networksetup -setdnsservers "Thunderbolt Ethernet Slot 1" 10.0.0.2 1.1.1.1
networksetup -getdnsservers "Thunderbolt Ethernet Slot 1"
sudo networksetup -setdnsservers "Thunderbolt Ethernet Slot 1" Empty
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
While the manual servers were set, scutil --dns listed both of them under resolver #1. After Empty, -getdnsservers answered There aren't any DNS Servers set on Thunderbolt Ethernet Slot 1., which means DHCP owns DNS again, not that DNS is broken. Use scutil --dns rather than cat /etc/resolv.conf to see what macOS resolves with: the file holds one search domain and one nameserver, while scutil also prints the per-domain mDNS resolvers for .local and the reverse zones, which a resolv.conf can’t express. The ifconfig, ip and DNS details have their own page on the ip and ifconfig commands on macOS.
pmset settings belong to a power source
A pmset setting is not global. Each value is stored per power source, and the flag before the setting picks which one you change:
-aall sources-ccharger (AC power)-bbattery-uUPS
So sudo pmset -c sleep 0 keeps a MacBook awake on the charger and still lets it sleep on battery, which is usually what you want. A desktop Mac only has the AC profile: pmset -g custom on the Mac mini printed a single AC Power: block and pmset -g batt answered Now drawing from 'AC Power'. Read the active values with pmset -g; a sudo pmset -a displaysleep 15 showed up there as displaysleep 15 immediately, with no restart.
Does your Mac refuse to sleep with every timer set? Then the settings are not the cause. Some process holds a power assertion, and pmset names it for you. To see one appear, start a 30-second caffeinate in the background and ask:
caffeinate -i -t 30 &
pmset -g
pmset -g assertions
The sleep line of pmset -g now ends in (sleep prevented by caffeinate, powerd), and the assertions list shows the caffeinate PID holding PreventUserIdleSystemSleep, with the seconds left before it lets go:

On your own Mac, look for a non-zero PreventUserIdleSystemSleep or PreventUserIdleDisplaySleep count, then read the owners underneath: a browser tab playing media, a backup client or a forgotten caffeinate are the usual ones. That makes caffeinate the clean way to keep a Mac awake for one job, such as caffeinate -i rsync -a ~/Projects/ /Volumes/Backup/Projects/, because the assertion lasts exactly as long as the command. A headless Mac mini that runs builds or a local model needs the opposite, a permanent sleep 0; the buying side of that setup is in the guide to the best Mac mini for AI agents.
Scheduled wakes are separate from both, and you set them once. sudo pmset repeat wakeorpoweron MTWRF 08:00:00 showed up in pmset -g sched as wakepoweron at 8:00AM weekdays only. It stays in the power settings until you remove it, and sudo pmset repeat cancel did that, leaving pmset -g sched empty.
defaults write changes preferences, not behaviour
A defaults write stores a key in a preference domain and nothing more. Whether anything changes depends on the app reading that key, and Finder and the Dock read theirs at launch, so a successful write with no visible effect usually means the app is still running with the old value. That is why most Finder and Dock tweaks end in a killall. The sequence below writes two keys, checks their types and removes one.
defaults write com.apple.finder AppleShowAllFiles -bool true
defaults read-type com.apple.finder AppleShowAllFiles
defaults write com.apple.dock autohide-delay -int 1
defaults read-type com.apple.dock autohide-delay
defaults delete com.apple.dock autohide-delay
killall Dock
Three things in the result are worth reading closely. Before the first write, defaults read com.apple.finder AppleShowAllFiles failed with Domain 'com.apple.finder' not found, which only means nothing has been saved yet, not that the key is wrong. The -int 1 write changes the type with no warning: an earlier run had stored the same key with -float 0, and after the integer write read-type says Type is integer. And killall Dock answered No matching processes belonging to you were found, because an SSH session has no Dock to restart:

A silent type change is the trap. defaults writes whatever type you pass, and an app that expects a boolean or a float may ignore a key of another type, so check an existing key with read-type before you overwrite it. These tweaks wrote and read back cleanly on macOS 27, each with the process it needs restarted:
com.apple.finder AppleShowAllFiles: Findercom.apple.finder ShowPathbar: Findercom.apple.dock autohide-delay: Dockcom.apple.desktopservices DSDontWriteNetworkStores: log out and back in
Before you make a batch of changes, keep a copy with defaults export com.apple.dock dock-backup.plist, then plutil -p dock-backup.plist shows what you saved. Undo a single key with defaults delete, which puts the app back on its built-in default; reading the key afterwards returns Could not find key 'autohide-delay' in domain 'com.apple.dock', the proof it’s gone. Avoid editing the .plist files under ~/Library/Preferences directly, because the cfprefsd daemon caches preferences in memory and can write its copy back over your edit.
launchctl load is the legacy path
launchd is the Mac’s systemd, and launchctl is its systemctl. Most tutorials still tell you to run launchctl load, but the man page on macOS 27 files load and unload under LEGACY SUBCOMMANDS and names bootstrap, bootout, enable and disable as the replacements. The reason to switch showed up in testing: a launchctl load that failed printed Load failed: 5: Input/output error and still exited 0, so a setup script would have carried on as if the job were running. bootstrap returned exit code 5 for the same failure.
The new commands take a domain target, and the folder holding the plist decides which domain the job belongs in:
~/Library/LaunchAgents:gui/$(id -u), while you’re logged in/Library/LaunchAgents: every user’s desktop session/Library/LaunchDaemons:system, as root from boot/System/Library/LaunchDaemons: Apple’s own, protected by SIP
What happens when you bootstrap an agent into gui/ over SSH? It fails with Bootstrap failed: 125: Domain does not support specified action, because the gui domain only exists for a user logged in at the desktop. The user/$(id -u) domain did not help either. From SSH it returned 5: Input/output error, even with sudo. On a headless Mac you manage over SSH, a job that must run without anyone logged in belongs in /Library/LaunchDaemons anyway, so that’s the path tested end to end here. Create the plist:
sudo vim /Library/LaunchDaemons/com.example.backup.plist
This job appends a timestamp to a log every 300 seconds, which is enough to prove it runs. Swap the shell command for your real backup script:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.backup</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>date >> /tmp/com.example.backup.log</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
</dict>
</plist>
The launchctl man page requires daemon plists to be owned by root and closed to group and world writes, so set the ownership and mode, then lint the file before loading it. A broken plist gets a precise answer from plutil (Value missing for key inside <dict> at line 15 for a dangling key), while launchd only says the load failed:
sudo chown root:wheel /Library/LaunchDaemons/com.example.backup.plist
sudo chmod 644 /Library/LaunchDaemons/com.example.backup.plist
plutil -lint /Library/LaunchDaemons/com.example.backup.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.backup.plist
sudo launchctl kickstart -k system/com.example.backup
A StartInterval job does not run the moment it loads, which is why the kickstart is there: it forces one run so you can check the result without waiting five minutes. The capture shows the whole cycle, from the gui error to runs = 1, last exit code = 0 and a timestamp in the log:

In launchctl list, the three columns are the PID, the last exit status and the label. A dash in the PID column is normal for a job between runs, a non-zero status means its last run failed, and a negative one means a signal killed it. The full print output (path, arguments, environment, run count) is for people, not parsers: the man page says it “does not constitute an API”. Three errors you’ll meet while iterating:
Bootstrap failed: 5: Input/output error: often already loaded, so check with printBoot-out failed: 3: No such process: nothing by that label is loadedCould not find service ... in domain: wrong domain or label
After editing the plist, run bootout and bootstrap again, since kickstart -k only restarts the job with the definition launchd already holds. disable and enable only flip a persistent override; sudo launchctl print-disabled system listed "com.example.backup" => disabled after one and enabled after the other, and neither unloaded the job, since the bootout afterwards still found it. When you’re done with it, remove the job with sudo launchctl bootout system/com.example.backup, then delete the plist. Apple’s own walkthrough is the script management with launchd page in the Terminal User Guide.
mdfind asks the index, find walks the disk
find works on a Mac exactly as on Linux, and on a large home folder it’s just as slow. mdfind queries the Spotlight index instead, so it answers almost at once and searches file contents as well as names. On a nearly empty home folder the gap was already 0.011 seconds for mdfind -name invoice against 0.129 for the equivalent find ~, and it grows with every file you own.
For the test, two small runbook files and a PDF went into ~/Documents/runbooks. You can then search for a phrase inside them and for PDFs by type.
mdfind -onlyin ~/Documents "kubernetes upgrade" 2>/dev/null
mdfind -onlyin ~/Documents 'kMDItemContentType == "com.adobe.pdf"'
mdls -name kMDItemContentType -name kMDItemKind -name kMDItemFSSize ~/Documents/runbooks/k8s-upgrade-notes.pdf
The phrase search found both the text file and the PDF, and the type query found only the PDF. mdls shows why you should query on kMDItemContentType (a UTI such as com.adobe.pdf) rather than kMDItemKind: the kind is the localized string PDF document, which changes with the system language:

Three behaviours from the run change how you script against mdfind:
- New files take seconds to appear: a search 10 seconds after writing them came back empty, and
mdlsprinted(null) mdfind -nameprints two[UserQueryParser] Loading keywordslines to stderr on macOS 27, so add2>/dev/null- Results include system paths:
-name invoicealso matchedINVoiceShortcut.hin the Command Line Tools SDK
Scope with -onlyin when you want results from one tree, and fall back to find for volumes where mdutil -s reports indexing disabled. Metadata queries combine with &&, so mdfind 'kMDItemContentType == "com.adobe.pdf" && kMDItemFSSize > 50000000' returns every PDF over 50 MB the index knows about. On the test Mac that list was empty, which is the right answer for a fresh machine.
Desktop tools fail over SSH
A handful of the commands people love most about the Mac terminal talk to the logged-in desktop, not to the system. Run them from an SSH session to a headless Mac and they fail, some with a clear error and some silently, which is easy to misread as a broken install. Over SSH on the test Mac:
pbcopyexited 1 with no messageopen .failed withLaunchd could not find jobscreencapture -xprintedcould not create image from displaykillall Dockandkillall Finderfound no process
You are seeing the same cause in all of them as in the launchctl 125 error, which is no gui session for your user. In Terminal on the Mac itself, each works as the table describes. Over SSH, you copy files with scp instead of the clipboard, and use a LaunchDaemon rather than an agent for anything that has to run without a login. The same session also shows the BSD sed difference covered next:

At the end of that capture sits meminfo, Apple’s memory breakdown, which reports pages and megabytes per category. It’s the closest thing to free -h on a Mac, and it does the page maths for you. vm_stat only prints page counts, and sysctl -n hw.pagesize returned 16384 on the M4, so multiplying those counts by 4096 out of Linux habit gives you a quarter of the real figure.
Linux habits that change on a Mac
Most of the confusion on a Mac terminal comes from muscle memory. macOS ships BSD versions of the core utilities and its own tools for the hardware, so the Linux command you type either does not exist or takes different flags. The left column is what you would type on a Linux box, and every Mac command in the middle column ran on the test machine.
| On Linux | On a Mac | What changes |
|---|---|---|
lsblk, fdisk -l | diskutil list | Disk identifiers, synthesized APFS containers |
lscpu, free -h | sysctl, meminfo | vm_stat counts 16 KB pages |
ip a, nmcli | ipconfig getifaddr, networksetup | Service names instead of interfaces |
systemctl | launchctl | Domains: gui/UID and system |
journalctl -u sshd | log show --predicate 'process == "sshd"' --last 1h | Unified log, predicate filters |
hostnamectl | scutil --get ComputerName | Three names: ComputerName, LocalHostName, HostName |
locate | mdfind | Uses the Spotlight index |
xclip, xdg-open | pbcopy, open | Built in, desktop session only |
sed -i 's/a/b/' f | sed -i '' 's/a/b/' f | BSD sed needs a backup suffix, even an empty one |
The sed -i row catches more scripts than any other line here. GNU-style sed -i "s/x/y/" notes.txt on a Mac takes the expression as the backup suffix and then parses the file name as a command, which is why the error reads extra characters at the end of n command: the n is the first letter of notes.txt. Pass an empty suffix and it works. If you’d rather keep GNU behaviour, Homebrew’s gnu-sed installs it as gsed, and keeping Homebrew auto-update under control stops that quick install from turning into a long update.
The hostname row is the other surprise. scutil keeps three separate names, and on the test Mac ComputerName was Mac mini, LocalHostName was Mac-mini (the Bonjour .local name) and HostName was not set at all, so the shell prompt falls back to the local name. Set the one your tooling reads, and check the other two before you blame DNS. Git, SSH keys and compilers come with the Xcode Command Line Tools, which softwareupdate -l listed as version 27.2 alongside the macOS 27.2 update on this machine.