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

  1. 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.
  2. 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).
  3. List files and folders with ls. Type ls and press Return to see contents of your current directory. Add flags for more detail: ls -la shows hidden files (like .bashrc), permissions, and file sizes.
  4. Change directories using cd. To move into your Documents folder, type cd Documents and press Return. To go back one level, type cd ... To jump straight to your home folder, type cd (without arguments) or cd ~.
  5. Create new directories with mkdir. Type mkdir Projects to make a new folder named Projects in your current location. You can chain paths: mkdir ~/Desktop/TodoList creates a folder on your Desktop.
  6. Create or edit text files using touch and a simple editor. Type touch notes.txt to create a blank file. To edit it, type open -e notes.txt, which opens it in TextEdit. Alternatively, use nano notes.txt to edit directly in Terminal (press Control + O to save, Control + X to exit).
  7. Move or rename files with mv. To rename notes.txt to todo.txt, type mv notes.txt todo.txt. To move it to your Desktop, type mv todo.txt ~/Desktop/.
  8. Copy files using cp. Type cp todo.txt backup.txt to duplicate the file. For folders, add the recursive flag: cp -r Projects ~/Desktop/.
  9. Delete files safely with rm. Type rm backup.txt to delete the file permanently. To delete a folder and its contents, use rm -r Projects. Warning: Deleted items bypass the Trash—use rm -i filename to add a confirmation prompt before deletion.
  10. View running processes with ps. Type ps to see processes you own. For a full list, type ps aux. To find a specific app, pipe it: ps aux | grep Safari shows all Safari-related processes.
  11. Stop a misbehaving process using kill. First, get its Process ID (PID) from ps aux | grep [appname]. Then type kill [PID] (e.g., kill 1234). If the process ignores that, use kill -9 [PID] to force-quit it.
  12. 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, use du -sh ~/Documents (summarize, human-readable).
  13. View system info quickly. Type system_profiler SPHardwareDataType for CPU, memory, and serial number details. For a shorter summary, use uname -a to show kernel version and machine architecture.
  14. Use man [command] for help on any command. Type man ls to read the full manual page for ls. 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).