Operations 20 min read

Unlock Your Mac’s Power: Essential Terminal Commands for Everyday Tasks

This guide explains what the macOS Terminal is, how to open it, basic command syntax, essential everyday commands for file and system management, and advanced utilities like defaults, textutil, diskutil, and Homebrew, while warning about risky operations and best practices.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Unlock Your Mac’s Power: Essential Terminal Commands for Everyday Tasks

What Is the Terminal?

The terminal is a bridge between the kernel and the user interface, allowing users to send commands directly to the system core and receive immediate feedback, effectively giving it control over the entire computer.

How to Open the Terminal

You can launch the Terminal app from the Applications folder or by using Spotlight: press ⌘Space, type "Terminal" (or "终端"), and hit Return.

Basic Knowledge

A command consists of an executable (the command object) optionally followed by flags or options that modify its behavior, and finally the arguments or data the command operates on.

Examples: say hi – makes the computer speak the word "hi". say -r 500 hi – speaks "hi" at a slower rate. echo "Your text" – prints the supplied text back to the terminal. pwd – displays the current working directory. cd /Applications – changes the working directory to the Applications folder. ls – lists files in the current directory; ls -R lists recursively. clear – clears the terminal screen.

Paths can be absolute (e.g., /Users/YourName) or relative (e.g., ./Utilities when already in /Applications).

Common Practical Commands

defaults write com.apple.CrashReporter DialogType none

– disables crash report dialogs.

defaults write com.apple.CrashReporter DialogType crashreport

– re‑enables them. touch -t 199505090000 /path/to/file – sets a file’s timestamp. caffeinate – prevents the Mac from sleeping; stop with Ctrl‑C. killall WeChat – force‑quits the WeChat application. defaults write com.apple.screencapture type jpg – changes screenshot format to JPEG; revert with defaults write com.apple.screencapture type png.

defaults write com.apple.screencapture disable-shadow -bool true; killall SystemUIServer

– removes the shadow from window screenshots; set false to restore.

defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder

– shows hidden files; set false to hide again.

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' ; killall Dock

– adds a spacer to the Dock. defaults delete com.apple.dock; killall Dock – resets the Dock to its default layout. banner -w 80 legolas.me – prints large‑style ASCII text.

Advanced Tutorials

defaults commands modify system‑wide property list (plist) files that store default preferences for applications.

To explore available plists, open Finder, press Option, choose "Go → Library", and browse the Preferences folder.

textutil converts documents between formats (txt, html, rtf, doc, docx, odt, etc.). Example: textutil -convert txt /path/to/file.docx diskutil manages disks and volumes. Basic safe commands: diskutil list – shows current disk layout. diskutil cs list – shows CoreStorage logical volume information.

Risky commands (use with extreme caution):

sudo diskutil resizeVolume /dev/disk1s3 limits
sudo diskutil eraseVolume free none diskX

– erases an entire disk. gpt remove -I 4 /dev/disk1 – removes a partition.

Homebrew is a macOS package manager. Install it with:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installation, use brew install <em>package</em> to add software.

rm deletes files. The dangerous form sudo rm -rfv /Cool recursively deletes everything from the root directory, potentially rendering the system unusable. The article demonstrates the destructive effect by running a similar command in a Fedora VM, which caused massive data loss on the host Mac.

Understanding sandboxing and virtual machines helps prevent such accidents: a sandbox isolates a VM’s actions from the host system.

Conclusion

The terminal can be used for simple, time‑saving tasks or for deep system customization. Most commands shown are harmless, but always verify a command’s effect before executing, especially those requiring sudo, as misuse can cause irreversible damage.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

productivitycommand-lineterminal
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.