Shell
which
Show the path of a command found in PATH.
pathexecutablecommandshell
Additional Notes
which searches the directories in PATH and prints the executable file that would be found for a command name. It is useful for quick checks like finding whether python, node, or ssh is installed and where it lives.
which usually only answers executable path lookup. Shell aliases, functions, keywords, and builtins may need type, command -v, or declare -f for a complete shell-aware answer.
Syntax
which [options] command...
Parameters
command: Command name to search for inPATH.options: Output behavior flags.
Common Options
-a: Show all matching executables inPATH, not just the first one.--help: Show help when supported.--version: Show version information when supported.
Examples
which python
Show the first python executable found in PATH.
which -a node
Show every node executable found in PATH order.
which ssh
Find the SSH client executable.
command -v cd
Use shell-aware lookup for a builtin like cd.
Practical Notes
PATHorder matters. The first matching executable wins.- Use
type COMMANDwhen aliases, shell functions, builtins, or keywords matter. - In portable scripts,
command -v COMMANDis often preferable towhich COMMAND.