Locate the executable that would be run for a given command.
low risk
which searches PATH directories for the specified command and prints the full path. Essential for diagnosing 'command not found' errors, verifying which version of a tool is active, and understanding PATH resolution order.
| Flag | Meaning |
|---|---|
-a --all | Print all matching paths, not just the first |
which kubectlFind where kubectl is installed · explain & risk-check →which -a python3Find all python3 installations in PATH · explain & risk-check →which terraform && terraform versionVerify terraform exists then check version · explain & risk-check →Use `which -a <cmd>` when debugging version conflicts — it reveals all installed copies so you know exactly which one your PATH resolves to first.
Reference text is hand-written and may be incomplete — check man which for your version. Test destructive commands on a non-production system first.