50 macOS Terminal Commands Worth Knowing: The Working Set, Organised by Job

Every Mac ships with a full command-line toolkit that most owners never open. Terminal looks intimidating, but the useful core is small: about fifty commands cover finding your way around, moving files, checking the system's health, fixing network problems, managing disks and updates, and keeping the machine awake or locked down. This article organises those fifty by the job they do, with the form of each command as Apple's own manual pages document it. Every command below is read from the built-in manual — type man followed by any command name on your own Mac and you get the same documentation this article was written from. Educational throughout, for machines you own or administer.

How to read this list safely

Three habits make Terminal safe to learn on. First, read before you run: man <command> shows the manual, and the -h or --help flag on many tools prints a short summary. Second, prefer the read-only form first — listing, checking and verifying change nothing; the commands that delete, erase or reformat are flagged in their sections below. Third, be suspicious of any command pasted from the internet that begins with sudo and pipes a download straight into a shell; the fifty here are all built into macOS itself, so none of them needs a download at all.

Find your way: orientation and search (1–6)

1. man — the manual itself. man diskutil opens the full documentation for a command; press Q to quit. This is the primary source for everything in this article. 2. pwd — print working directory: where you are in the folder tree right now. 3. ls — list a folder's contents. ls -lah adds hidden files, long details and human-readable sizes. 4. cd — change directory. cd ~ returns home; cd - jumps back to the previous folder. 5. mdfind — search the whole Mac through the Spotlight index. mdfind -name report finds files by name in seconds, because it queries an index instead of walking the disk. 6. which — show which program a command name actually runs, and where it lives. The first check when a command behaves unexpectedly.

Files and folders (7–16)

7. mkdir — make a directory; mkdir -p a/b/c creates the whole nested path at once. 8. touch — create an empty file, or update an existing file's timestamp. 9. cp — copy files; cp -R copies a folder and everything inside it. 10. mv — move or rename. On the same volume it is instant, because only the directory entry changes. 11. rm — remove files permanently; there is no Trash and no undo. Learn it as rm -i, which asks before each deletion, and never run a pasted rm -rf you have not read word by word. 12. ditto — macOS's own heavy-duty copier. It preserves resource forks and metadata that plain cp can drop, which is why installers and backup scripts use it. 13. find — walk the real filesystem and match by name, size, age or type: find ~ -name "*.log" -mtime +30 finds logs older than thirty days. 14. du — disk usage per folder. du -sh ~/Downloads answers "what is eating my disk" one folder at a time. 15. df — free space per mounted volume. df -h / shows the startup disk in human-readable form. 16. stat — the full record of one file: size, permissions, owner, and every timestamp macOS keeps for it.

Text, clipboard and preferences (17–23)

17. less — page through a file or long output without loading it into an editor; / searches inside it, Q quits. 18. grep — search text by pattern. grep -rn "error" ~/logs hunts a word through a folder of logs and prints file and line number for each hit. 19. pbcopy — pipe anything into the clipboard: cat notes.txt | pbcopy, then paste anywhere with Command-V. 20. pbpaste — the reverse: print whatever is on the clipboard into the terminal or a file, pbpaste > saved.txt. 21. textutil — convert documents between formats — Word, RTF, HTML and plain text — without opening an editor: textutil -convert txt file.docx. 22. plutil — inspect and validate property-list files, the preference format macOS is built on. plutil -lint checks one for corruption before you trust it. 23. defaults — read and write application preferences directly: defaults read com.apple.finder shows a whole domain; a defaults write followed by restarting the app is how many documented settings are applied. Read first, write second, and note the old value before you change it.

System information and control (24–32)

24. sw_vers — the macOS version, build number and product name, in three lines. The first thing to quote in any bug report. 25. system_profiler — the full hardware and software inventory: serial number, storage, battery cycle count, attached USB devices. system_profiler SPHardwareDataType limits it to the machine itself. 26. top — the live process table, sorted by CPU use. When the fans spin up, top names the process responsible. 27. ps — a snapshot of processes. ps aux lists every process with its owner and resource use; pair it with grep to find one program. 28. killall — end every process with a given name: killall Finder restarts the Finder, the standard fix for a stuck desktop. It is a blunt instrument — unsaved work in the named app is lost. 29. launchctl — control launchd, the system that starts and supervises services and login agents. launchctl list shows what is loaded and its last exit status — the map of what runs your Mac behind the scenes. 30. softwareupdate — Apple's update system from the command line. softwareupdate -l lists what is available; installing is an administrator action, and on your own Mac System Settings remains the same system in graphical form. 31. uptime — how long the machine has been running, and its load averages. A reboot you do not remember is a clue worth chasing. 32. log — read the unified system log. log show --last 1h --predicate 'eventMessage contains "error"' is how you ask the system what it was complaining about an hour ago.

Disks, images and backups (33–37)

33. diskutil — the command-line Disk Utility: diskutil list maps every disk, APFS container and volume; diskutil verifyVolume / checks the startup volume's filesystem. Its erase and reformat verbs are destructive — verify the disk identifier twice before using them. 34. hdiutil — create, attach, verify and convert disk images (.dmg files). hdiutil verify checks an image's checksum before you install from it. 35. tmutil — control Time Machine: tmutil status shows a backup in progress, tmutil latestbackup names the most recent completed one, and tmutil destinationinfo shows where backups go. 36. sips — the scriptable image-processing system: resize, rotate, convert and read the pixel dimensions of images in bulk, sips -Z 1024 photo.jpg being the everyday form. It overwrites the original unless you give it an --out path — work on copies. 37. screencapture — take screenshots from the shell, to a file or the clipboard, whole screen or a selected window — the tool behind scripted documentation and bug reports.

Network diagnosis (38–45)

38. ipconfig — on macOS this reads the IP configuration (it is not the Windows tool of the same name): ipconfig getifaddr en0 prints the Wi-Fi interface's current address. 39. networksetup — read and change network service settings: networksetup -listallnetworkservices names the services, and its getters report DNS servers, proxies and Wi-Fi state per service. Changes here are real settings changes — read with the getters first. 40. scutil — the system configuration utility: scutil --dns prints the full DNS resolver configuration macOS is actually using, which settles most "the internet is broken" arguments. 41. ping — test basic reachability and latency to a host. A diagnostic, not a verdict: many servers ignore ping by policy. 42. dig — query DNS directly and see the answer, the server that gave it and how long it took. When a site "does not exist" for you, dig shows whether DNS or the site is at fault. 43. netstat — network statistics and routing tables; netstat -rn prints the routing table, including the default gateway your traffic actually uses. 44. lsof — list open files — and because sockets are files on Unix, lsof -i :8080 names the process holding a network port. The definitive answer to "what is using this port." 45. curl — transfer data from a URL and show exactly what the server answered, headers included with -I. The fastest honest check of what a web server is really doing.

Power and security (46–50)

46. pmset — power management settings and diagnostics. pmset -g assertions lists every process currently preventing sleep and why — the direct answer to "why won't my Mac sleep." Changing sleep behaviour with pmset is an administrator action. 47. caffeinate — keep the Mac awake for a job: caffeinate -i <command> holds off idle sleep until that command finishes, and -t 3600 holds it for one hour. It creates a temporary power assertion; it does not rewrite your sleep settings, and pmset -g assertions shows the hold while it lasts. 48. spctl — assess Gatekeeper: spctl --assess --verbose <app> reports whether macOS accepts an app's signature and notarization. Checking is the defensive use; weakening Gatekeeper is not a fix for an app that fails assessment. 49. security — the Keychain and security-framework tool: list keychains, inspect certificates and check trust settings from the shell. Powerful and sensitive — prefer its read-only queries, and never paste commands that export passwords you have not reviewed. 50. xattr — read and clear extended attributes, including the quarantine flag macOS attaches to downloads (com.apple.quarantine). Knowing the flag exists explains many "unidentified developer" prompts; clearing it on software you do not trust defeats the warning instead of answering it — check the app with spctl first.

The fifty as a one-page checklist

Orientation: man, pwd, ls, cd, mdfind, which. Files: mkdir, touch, cp, mv, rm, ditto, find, du, df, stat. Text and preferences: less, grep, pbcopy, pbpaste, textutil, plutil, defaults. System: sw_vers, system_profiler, top, ps, killall, launchctl, softwareupdate, uptime, log. Disks and backups: diskutil, hdiutil, tmutil, sips, screencapture. Network: ipconfig, networksetup, scutil, ping, dig, netstat, lsof, curl. Power and security: pmset, caffeinate, spctl, security, xattr. Fifty commands, all built in, all documented by the first one on the list. Learn the read-only forms first, keep man open beside you, and Terminal stops being a hazard and becomes what it is on every Mac: the most direct diagnostic tool the machine ships with.

By Karl Amber

Sources

– Apple — the macOS manual pages themselves, installed with every Mac and read with the man command: man pages for caffeinate, pmset, networksetup, scutil, defaults, plutil, diskutil, hdiutil, tmutil, softwareupdate, spctl, security, xattr, sips, screencapture, mdfind, ditto, launchctl, log, lsof and the standard utilities (ls, cp, mv, rm, find, grep, ps, top, dig, curl and the rest). – Apple — Terminal User Guide (support.apple.com/guide/terminal): Terminal basics, executing commands, and using the command line on Mac. – Apple — macOS security documentation on Gatekeeper and notarization (developer.apple.com): what spctl assessment checks — a valid signature and Apple notarization.

Editor's note: this article is part of ScanderLoud's Cybersecurity & Networking series. It was researched from primary and authoritative sources — Apple's own manual pages as shipped with macOS, the Terminal User Guide, and Apple's Gatekeeper/notarization documentation — and is original, educational, and defensive throughout. No NetworkChuck video was opened or used.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *