How to Fix ‘zsh: command not found’ in macOS Terminal

Starting with macOS Catalina, Apple transitioned the default interactive shell from Bash to Zsh (Z Shell). When executing command-line utilities, developer tools, or package managers in Terminal, receiving the notification “zsh: command not found” indicates that the Zsh shell cannot locate an executable binary matching the name you typed. While typographical errors are a common reason, this error frequently occurs because software installation directories are missing from the global PATH environment variable, configuration files (such as .zshrc) were wiped during operating system upgrades, or Apple Silicon Homebrew paths were never registered.

Verify Command Spelling and Check Installation Status

Before modifying shell profile configurations, confirm whether the requested utility is physically installed on the local file system.

  1. Inspect the command name for case-sensitivity or typographical errors (UNIX commands are strictly lower-case).
  2. Use the which or where command to query the active environment:
    which python3
    which brew
  3. If Terminal outputs no path, check standard installation directories manually using ls:
    ls /opt/homebrew/bin
    ls /usr/local/bin
  4. If the binary file exists in one of these directories, the tool is installed but invisible to Zsh due to a misconfigured PATH variable.

Add Homebrew Binaries to the Zsh PATH on Apple Silicon

On Apple Silicon Macs (M1, M2, M3, M4 series), Homebrew installs packages into /opt/homebrew/bin to avoid conflicts with Rosetta 2 x86 binaries (which reside in /usr/local/bin). Fresh Homebrew installations do not add this path automatically.

  1. Open Terminal on your Mac.
  2. Run the following command to append the Homebrew initialization script to your user profile:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
  3. Verify that Homebrew is now recognised:
    brew --version
  4. Packages installed through Homebrew (such as node, git, python, and wget) will now be directly callable from any terminal prompt.

Export Standard Directories in .zshrc Profile

The PATH variable contains a colon-separated list of directories searched sequentially when executing commands.

  1. Open your user Zsh configuration file in the nano editor:
    nano ~/.zshrc
  2. Scroll to the bottom of the file and paste the comprehensive standard PATH export line:
    export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
  3. If you use Python, Ruby, or Rust, append their respective binary paths:
    export PATH="$HOME/.cargo/bin:$HOME/Library/Python/3.9/bin:$PATH"
  4. Press Ctrl + O and Enter to save the changes, then press Ctrl + X to exit nano.
  5. Reload the profile into your current shell session immediately:
    source ~/.zshrc

Reinstall Xcode Command Line Tools

Standard developer utilities like git, make, gcc, and clang are provided through Apple Command Line Developer Tools. Major macOS updates often break the symbolic developer directory links.

  1. Trigger a clean reinstallation prompt in Terminal:
    xcode-select --install
  2. A graphical dialogue will appear; click Install and accept the license terms.
  3. If the system claims the tools are already installed, reset the active developer directory:
    sudo xcode-select --reset

Restore Corrupted System Shell Files

If you accidentally altered or deleted standard macOS environment scripts, Terminal loses access even to basic commands like ls, cp, or mkdir.

  1. Temporarily restore basic terminal access by prefixing standard system paths:
    /bin/echo $PATH
  2. Verify that the core system path file exists:
    /bin/cat /etc/paths
  3. The file should contain:
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
  4. Restart Terminal. All native macOS utilities will execute without issue.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.