PATH is a list of folders where your Mac looks for commands. When you type git or python or any command, your Mac searches these folders to find it.

If the command isn't in any PATH folder, you get "command not found."

See Your PATH

echo \$PATH

Output (example):

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Those are folders, separated by colons. Your Mac searches them in order.

How It Works

When you type a command like node:

  1. Mac checks /usr/local/bin/node - not there
  2. Mac checks /usr/bin/node - not there
  3. Mac checks /bin/node - not there
  4. No more folders → "command not found"

If Node was installed and added to PATH:

  1. Mac checks /usr/local/bin/node - found it!
  2. Runs the program

Common PATH Folders

Folder What's typically there
/bin Core system commands (ls, cp, mv)
/usr/bin Standard Unix commands
/usr/local/bin User-installed programs (Intel Mac Homebrew)
/opt/homebrew/bin Homebrew programs (Apple Silicon)
~/bin Your personal scripts

Why "command not found" Happens

The program exists, but its folder isn't in PATH. Common examples:

  • Installed Homebrew but didn't add it to PATH
  • Installed Python but the binary is elsewhere
  • Downloaded a tool but it's in Downloads, not a PATH folder

Adding a Folder to PATH

Edit your shell config file:

nano ~/.zshrc

Add this line (example for Homebrew on Apple Silicon):

export PATH="/opt/homebrew/bin:\$PATH"

Save and reload:

source ~/.zshrc

Now that folder is in your PATH.

The Syntax Explained

export PATH="/new/folder:\$PATH"
Part Meaning
export PATH= Set the PATH variable
"/new/folder" The folder to add
: Separator between folders
\$PATH The existing PATH (so you don't lose it)

Putting your folder first means it gets searched first.

Check Where a Command Lives

which python3

Output: /usr/bin/python3

This shows the full path to the command. If which returns nothing, the command isn't in your PATH.

Multiple Versions Problem

If you have multiple versions of something (like Python), the first one found in PATH wins:

which python3

If this shows the wrong Python, the fix is to put the right folder earlier in PATH.

Common PATH Additions

Homebrew (Apple Silicon):

export PATH="/opt/homebrew/bin:\$PATH"

Homebrew (Intel):

export PATH="/usr/local/bin:\$PATH"

Python user packages:

export PATH="\$HOME/Library/Python/3.12/bin:\$PATH"

Your own scripts folder:

export PATH="\$HOME/bin:\$PATH"

Temporary vs Permanent

Temporary (current session only):

export PATH="/some/folder:\$PATH"

Disappears when you close Terminal.

Permanent (add to ~/.zshrc):

echo 'export PATH="/some/folder:\$PATH"' >> ~/.zshrc
source ~/.zshrc

Persists across sessions.

Debugging PATH Issues

See PATH folders one per line:

echo \$PATH | tr ':' '\n'

Check if a folder is in PATH:

echo \$PATH | grep -q "/opt/homebrew/bin" && echo "Yes" || echo "No"

Find all copies of a command:

type -a python3

Keep Learning

Understanding PATH solves most "command not found" problems. The free course covers this and other Terminal fundamentals.

Check it out at Mac Terminal for Humans.