Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Mac CMD Command: Open Terminal & Use It

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

On a Mac there is no cmd command the way there is on Windows. The macOS equivalent is Terminal, the built-in app that gives you a Unix shell (zsh by default). If you type cmd into Terminal you will get zsh: command not found: cmd. To get the same result as opening Command Prompt on Windows, open Terminal from Applications > Utilities, or press Command+Space, type Terminal, and press Return. From there you can run standard Unix commands such as ls, cd, pwd, mkdir, cp, mv, rm, and sudo for administrator tasks.

What You'll Need

  • A Mac running a current version of macOS (the steps below work on recent releases; menu labels can differ slightly by version and region).
  • An administrator account if you plan to use sudo or change system-level settings.
  • Basic familiarity with typing commands and pressing Return to run them.

Step-by-Step

  1. Open Terminal. Use Spotlight (Command+Space), type Terminal, and press Return. Alternatively, open Finder, go to Applications > Utilities, and double-click Terminal. You can also pin Terminal to the Dock by right-clicking its icon and choosing Options > Keep in Dock.
  2. Understand the prompt. You will see something like username@MacBook ~ %. The % means the shell is zsh and ready for a command. The ~ shows you are in your home folder.
  3. Check where you are. Type pwd and press Return. It prints the full path of your current folder, for example /Users/yourname.
  4. List files. Type ls and press Return to see the contents of the current folder. Use ls -l for a detailed list with sizes and dates, or ls -a to include hidden files.
  5. Change folders. Type cd Desktop to move into your Desktop folder, or cd .. to go up one level. Type cd alone to return to your home folder.
  6. Create a folder. Type mkdir testfolder and press Return. A new folder called testfolder appears in the current directory. Verify with ls.
  7. Create a file. Type touch notes.txt to create an empty file. To write text into it, use nano notes.txt, type your text, then press Control+O, Return to save, and Control+X to exit.
  8. Copy, move, and rename. cp notes.txt copy.txt makes a copy. mv copy.txt renamed.txt renames it. mv renamed.txt testfolder/ moves it into the folder you created.
  9. Read a file. Type cat notes.txt to print its contents in the Terminal window. For long files, use less notes.txt and press Q to quit.
  10. Remove a file or folder. rm notes.txt deletes a file. rm -r testfolder deletes a folder and everything inside it. There is no Trash and no undo, so double-check the name before pressing Return.
  11. Run a command as administrator. Prefix it with sudo, for example sudo nano /etc/hosts. You will be asked for your login password; typing it shows no characters, which is normal. Press Control+X to exit the editor when done.
  12. Close Terminal. Type exit and press Return, or press Command+Q. Closing the window ends the shell session.

Common Mistakes

  • Typing Windows commands. dir, cls, copy, and cmd do not exist on macOS. Use ls, clear, and cp instead.
  • Forgetting spaces. Commands and their options need spaces: ls -l, not ls-l.
  • Using rm -r carelessly. It permanently deletes folders and their contents. Never run it on a path you have not checked with ls first.
  • Assuming sudo is always needed. Most everyday commands work without it. Use it only when a command fails with a permission error and you understand what the command does.
  • Pasting commands from the web without reading them. A command can delete files or change settings. Read it first, especially anything with sudo or rm.

Tips

  • Press Tab to auto-complete file and folder names, which reduces typos.
  • Press the Up arrow to recall previous commands.
  • Press Control+C to cancel a command that is running or stuck.
  • Use man ls (or man plus any command) to read its manual; press Q to exit.
  • Drag a file from Finder into the Terminal window to insert its full path automatically.
  • Keep a note of any command that changes system files, so you can reverse it if needed.

Troubleshooting

  • command not found: Check spelling and spacing. If the command is a tool you installed, confirm it is on your PATH; reinstalling the tool from its official source usually fixes it.
  • Permission denied: The file or folder is read-only for your user. Confirm you are in the right folder with pwd and ls -l, and only use sudo if the task genuinely requires administrator rights.
  • Terminal opens but shows a strange prompt: Quit Terminal (Command+Q) and reopen it. If the problem persists, check that your shell configuration file (such as ~/.zshrc) has not been edited incorrectly; restore a backup or remove the last change.
  • A command seems frozen: Press Control+C to interrupt it. If that does not work, close the Terminal window and open a new one.
  • You deleted something by mistake: Terminal deletions do not go to the Trash. Check whether you have a backup (Time Machine or iCloud Drive) and restore from there.
  • You need to reset Terminal to defaults: Quit Terminal, then reopen it while holding the Shift key to start a fresh session, or remove custom settings from Terminal > Settings. This does not delete your files.

Frequently Asked Questions

Is there a cmd command on Mac?

No. macOS uses Terminal with a Unix shell. The closest equivalent to Windows Command Prompt is the Terminal app, and the commands are Unix commands such as ls and cd.

How do I open Terminal quickly?

Press Command+Space, type Terminal, and press Return. You can also open Finder > Applications > Utilities > Terminal.

Can I run Windows .bat or .cmd files on a Mac?

Not natively. Those files are written for Windows. You would need a virtual machine or a compatibility layer, and even then some commands will not work.

What is sudo and when should I use it?

sudo runs a single command with administrator privileges. Use it only when a command needs to change system-level files or settings, and only after you understand what the command does.

Does Terminal have a Trash?

No. Files deleted with rm are gone immediately. Recover them from a backup if you have one.

Can I change the default shell?

Yes. macOS includes zsh and bash. You can change your login shell in System Settings > Users & Groups (the exact label varies by macOS version) or with the chsh command. Leave the default unless you have a specific reason to change it.