PATH
A colon-delimited list of directories the shell searches for executable programs. When you run a command, the shell checks each directory in PATH from left to right until it finds a matching executable. This is one of the most fundamental environment variables on Unix-like systems.
Last updated:
PATH is the colon-separated list of directories your shell searches, left to right, to resolve a bare command name like `git` or `node`. Order is everything: the first match wins, so a directory earlier in PATH shadows the same binary later on. This is why `which node` and version managers (nvm, pyenv, rbenv) work by prepending their shim directory to PATH, and why 'command not found' after installing a tool almost always means its directory is not on PATH. On Windows the separator is a semicolon, not a colon.
- Provider
- General / OS
- Category
- system
- Set by
- Set by the shell profile files (~/.bashrc, ~/.zshrc, /etc/environment)
- Example
- /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
How to set PATH
add a directory (prepend, takes priority)
export PATH="$HOME/.local/bin:$PATH"add a directory (append, lowest priority)
export PATH="$PATH:/opt/tools/bin"inspect, one entry per line
echo "$PATH" | tr ':' '\n'References
Frequently Asked Questions
I installed a CLI but get 'command not found'. Why?
Its install directory is not on PATH, or the shell has cached the old PATH. Find the binary (e.g. `find / -name toolname 2>/dev/null`), add its directory with `export PATH="/that/dir:$PATH"` in your ~/.bashrc or ~/.zshrc, then open a new shell or run `hash -r` to clear the lookup cache.
Why does the wrong version of a tool run?
PATH is searched left to right and the first match wins. Another copy earlier in PATH is shadowing the one you want. Run `which -a toolname` to see every match in order, then reorder PATH so the directory you want comes first.
Stay up to date
Get notified about new guides, tools, and cheatsheets.