which
What is which?
which: Which — Show the full path of a command executable. which shows the full path of the program that runs when you type a command. which php might return /usr/bin/php or /opt/homebrew/bin/php. That helps when several versions are installed, which is common with PHP, Node and Python. If php -v shows a different version than you expect, which php tells you which one your shell actually finds first on the PATH.
Frequently asked questions about which
What should you keep in mind with which?
which -a php lists every match, in the order they are searched. type php in Bash also reports aliases and shell functions, which which may miss. If the wrong version is picked up, adjust the order of folders in your PATH, or use a version manager like nvm, phpbrew or asdf, which switch versions per project.
At a glance
| Category | CLI commands |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |