which
Explanation
The which command returns the pathnames of the files (or links) which would be executed in the current environment had its arguments been given as commands. It does this by searching the directories listed in the PATH environment variable.
Basic Syntax
which [options] [--] programname [...]
Common Flags and Options
| Flag | Description |
|---|---|
-a | Print all matching pathnames of each argument. |
Real-world Examples
-
Find the location of the
lsexecutable:which ls(Output might be
/bin/ls) -
Find the location of Python:
which python3 -
Find all executables named 'gcc' in your PATH:
which -a gcc