macOS Terminal and zsh for Complete Beginners

Learn how the macOS Terminal application, zsh shell, prompt, current directory, command path, help, and exit status fit together.

By Ian Fang Beginner 25 minutes

Time-sensitive details checked:

A student-centered editorial illustration representing macOS Terminal and zsh for Complete Beginners.

Terminal is a macOS application. zsh is the default shell that normally runs inside each Terminal window. The shell reads a command line, finds a command, and displays its result through Terminal. Keeping those layers separate makes setup and error messages easier to explain.

This article uses inspection commands and one disposable practice folder. Use a normal account, not a root shell, and do not add shell configuration. If the Mac’s owner, administrator, management, or recovery status is unclear, first establish a safe Mac starting state.

Read the window and prompt

Open Terminal from /Applications/Utilities or with Spotlight. Apple describes each Terminal window as an instance of a shell process in its guide to opening Terminal.

A prompt may resemble:

student@MacBook-Air ~ %

The exact prompt depends on settings. It may show the user, computer, current directory, and a prompt symbol. The % is not part of the command. When an example shows % pwd, type only:

pwd

Identify the three layers

Run these read-only commands one at a time:

whoami
echo "$SHELL"
ps -p $$ -o comm=
pwd
  • whoami reports the effective user.
  • $SHELL normally records the user’s configured login shell.
  • ps -p $$ -o comm= inspects the current shell process.
  • pwd prints the current working directory.

The configured login shell and current process can differ when another program starts a different shell. Record both instead of assuming.

Apple’s current Terminal settings guide identifies zsh as the default shell. A network administrator can set another default. Do not change the shell merely because a tutorial uses Bash; first determine what the course or tool actually requires.

See how zsh finds a command

Enter:

command -v pwd
command -v ls
printf '%s\n' "$PATH"

command -v asks zsh how it resolves a command name. A result may identify a shell built-in or an executable path. PATH is a colon-separated search list used when a command is entered without its full path.

Apple’s command-execution guide explains that tools in known PATH directories can be run without a complete pathname. A command not found message can therefore mean the tool is absent, misspelled, or outside the active search path. Installing another Terminal application does not by itself install the missing command.

Do not edit PATH during this exercise. Record the evidence first.

Practice in a safe directory

Make a folder through Finder named Terminal-Practice in your home folder. Then use read-only commands:

cd ~/Terminal-Practice
pwd
ls

Here, ~ represents your home directory. cd changes the shell’s current directory, pwd reports it, and ls lists entries.

Use Tab completion instead of retyping the whole directory name. Completion can reduce typing mistakes, but it does not prove that a command is safe.

Ask the installed system for help

Use the manual:

man pwd

Press q to leave the manual viewer. For zsh’s built-in behavior, start with:

man zshbuiltins

Manual pages describe the installed system. Online examples may target another macOS release, shell, processor architecture, or third-party command.

Check exit status

After a successful pwd, run:

echo $?

Then request a path that should not exist:

ls this-path-should-not-exist
echo $?

The second echo $? should report the status of the immediately preceding ls. Zero conventionally indicates success; nonzero indicates another result or failure whose exact meaning belongs to the command.

Visible text is not enough to establish success. Record the command, output, and status together.

Use history and interruption carefully

Press the Up Arrow to recall a previous line, then reread the entire command before running it. History can contain paths or sensitive values and is not a complete working log.

If a safe command continues longer than expected, Control-C asks most commands to stop. Apple documents history recall and Control-C in its Terminal command guide. Interruption can leave a state-changing command incomplete, so it is not a general undo operation.

Complete a Mac terminal inventory

## macOS terminal inventory

- Terminal application:
- Effective user:
- Configured login shell:
- Current shell process:
- Current directory:
- Resolution of `ls`:
- One manual page opened:
- Successful command and exit status:
- Failed read-only command and exit status:

Do not record secrets from environment variables, command history, or private paths.

Common mistakes

  • Calling Terminal, zsh, and every command β€œTerminal.”
  • Typing the prompt symbol from documentation.
  • Assuming $SHELL proves which process is running now.
  • Changing .zshrc before understanding the current environment.
  • Running practice commands with sudo.
  • Treating completion or visible output as proof of safety or success.
  • Pasting a Homebrew installer before reading what it will do.

Do this now

Complete the inventory with the read-only commands above. Explain one result using the words Terminal, shell, command, current directory, PATH, and exit status.

Log what you learned

The macOS terminal inventory is the learning log. Save the observed command resolution, path, exit statuses, and next question there.

Next, decide whether an app belongs under App Store or Homebrew management.

Further reading