which

Locate the executable that would be run for a given command.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

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.

Common flags
FlagMeaning
-a --allPrint all matching paths, not just the first
Examples
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 →
Pro tip

Use `which -a <cmd>` when debugging version conflicts — it reveals all installed copies so you know exactly which one your PATH resolves to first.

Related
whereis type find
Open the full explainer →More in Shell & Scripting

Reference text is hand-written and may be incomplete — check man which for your version. Test destructive commands on a non-production system first.