Mac OS basic commands let you control your Mac from the Terminal, enabling faster workflows, automation, and deeper system access. You don’t need to be an expert to use them—just know a few core commands and how to open the Terminal app. This guide covers the most useful, safe, and frequently used commands for everyday tasks like navigating files, managing processes, and checking system info.
What You'll Need
- A Mac running macOS (any modern version from macOS Catalina onward works identically for these commands)
- Access to the Terminal app (found in Applications > Utilities)
- Basic familiarity with your Mac’s file structure (e.g., Documents, Desktop, Downloads folders)
Step-by-Step
- Open the Terminal app. Press Command + Space to open Spotlight, type Terminal, and press Return. The app appears in the search results—click it to launch.
- Start with navigation commands. Type
pwd(print working directory) and press Return. This shows your current location in the file system (usually your home folder, e.g.,/Users/yourname). - List files and folders with
ls. Typelsand press Return to see contents of your current directory. Add flags for more detail:ls -lashows hidden files (like .bashrc), permissions, and file sizes. - Change directories using
cd. To move into your Documents folder, typecd Documentsand press Return. To go back one level, typecd ... To jump straight to your home folder, typecd(without arguments) orcd ~. - Create new directories with
mkdir. Typemkdir Projectsto make a new folder named Projects in your current location. You can chain paths:mkdir ~/Desktop/TodoListcreates a folder on your Desktop. - Create or edit text files using
touchand a simple editor. Typetouch notes.txtto create a blank file. To edit it, typeopen -e notes.txt, which opens it in TextEdit. Alternatively, usenano notes.txtto edit directly in Terminal (press Control + O to save, Control + X to exit). - Move or rename files with
mv. To rename notes.txt to todo.txt, typemv notes.txt todo.txt. To move it to your Desktop, typemv todo.txt ~/Desktop/. - Copy files using
cp. Typecp todo.txt backup.txtto duplicate the file. For folders, add the recursive flag:cp -r Projects ~/Desktop/. - Delete files safely with
rm. Typerm backup.txtto delete the file permanently. To delete a folder and its contents, userm -r Projects. Warning: Deleted items bypass the Trash—userm -i filenameto add a confirmation prompt before deletion. - View running processes with
ps. Typepsto see processes you own. For a full list, typeps aux. To find a specific app, pipe it:ps aux | grep Safarishows all Safari-related processes. - Stop a misbehaving process using
kill. First, get its Process ID (PID) fromps aux | grep [appname]. Then typekill [PID](e.g.,kill 1234). If the process ignores that, usekill -9 [PID]to force-quit it. - Check disk usage with
df -h(disk free). This shows storage space in human-readable format (GB/TB). To check the size of a folder, usedu -sh ~/Documents(summarize, human-readable). - View system info quickly. Type
system_profiler SPHardwareDataTypefor CPU, memory, and serial number details. For a shorter summary, useuname -ato show kernel version and machine architecture. - Use
man [command]for help on any command. Typeman lsto read the full manual page forls. Press Q to exit the manual viewer.
Common Mistakes
Avoid these frequent errors when using Mac terminal commands. First, never run sudo rm -rf /—even by accident—because it deletes your entire system. Always double-check paths before deleting or moving files. Second, avoid using sudo unless necessary; many users add it prematurely, which can cause permission issues or modify system files unintentionally. Third, forget that filenames with spaces require quotes or escaping: type cd "My Documents" or cd My\ Documents. Fourth, assume the command line is case-sensitive: Documents and documents are different folders. Fifth, skip the -i flag on rm when deleting important files, leading to irreversible mistakes. Sixth, ignore hidden files: ls won’t show them unless you use -a, which can cause confusion when a file appears missing.
Tips
Use Tab completion to avoid typos: type the first few letters of a filename or folder, then press Tab to auto-complete (e.g., type cd Doc and hit Tab to fill in Documents). Press Up and Down arrows to cycle through previous commands—great for re-running similar tasks. Chain commands with && to run them sequentially only if the prior one succeeds (e.g., mkdir NewFolder && touch NewFolder/notes.txt). Use clear or Command + K to clear the terminal window without closing it. Save time by creating aliases: type alias ll='ls -la' to make ll a shortcut for ls -la. Add this line to your ~/.zshrc file to make it permanent. Finally, run history to see your last 100 commands—useful for auditing or repeating complex tasks.
Troubleshooting
If a command doesn’t work, start with these checks. First, verify the command is spelled correctly and case matches (e.g., CD won’t work; only cd is valid). Second, confirm the file or folder path exists—type ls in the parent directory to see what’s there. Third, check permissions: if you see Permission denied, you may need to use sudo or change ownership with chown (but avoid sudo unless essential). Fourth, if a command isn’t found, ensure it’s installed: most built-in commands like ls and cd are always available, but third-party tools (e.g., brew) require Homebrew installation. Fifth, if the Terminal itself won’t open, restart your Mac and try again—sometimes a hung process blocks the app. Sixth, for persistent command not found errors, check your shell’s PATH: type echo $PATH and ensure it includes standard locations like /usr/bin and /bin. If all else fails, use man [command] to verify syntax or restart Terminal and try a simpler command first (e.g., pwd) to confirm the app works.
Frequently Asked Questions
Can I undo a rm command?
No—files deleted with rm bypass the Trash and are gone permanently. Always use rm -i to add a confirmation prompt, or copy files to a backup folder first before deleting.
How do I run a command with administrator privileges?
Prefix the command with sudo (e.g., sudo softwareupdate -i -a). You’ll be asked for your Mac login password (not the root password). Only use sudo for trusted commands.
Why does cd not work even when the folder exists?
Check for spaces in the path: use quotes (cd "My Folder") or escape spaces with a backslash (cd My\ Folder). Also confirm capitalization matches exactly—macOS file systems are case-sensitive by default.
How do I copy a folder and all its contents?
Use cp -r sourcename targetname (e.g., cp -r Projects ~/Desktop/). The -r flag tells cp to copy recursively into subfolders.
Is it safe to use kill -9?
It’s safe for unresponsive apps but can cause data loss if the process was saving files. Use kill [PID] first; only use kill -9 if the app ignores the first signal.
Where are terminal settings saved?
Terminal preferences (like fonts, colors, and shell profiles) are stored in ~/Library/Preferences/com.apple.Terminal.plist. Shell settings (like aliases and PATH) go in ~/.zshrc (for zsh, the default shell since macOS Catalina) or ~/.bash_profile (for older bash setups).