which
TLDR
Find the path of a command
SYNOPSIS
which [-a] command...
DESCRIPTION
which searches for executables in the directories listed in the PATH environment variable and prints the path of the first match found.
This is useful for determining which version of a command will be executed when multiple versions exist, or for confirming a command is installed and in your PATH.
With -a, all matches are shown, revealing if multiple versions exist in different PATH directories. The first listed is the one that would be executed.
PARAMETERS
-a, --all
Print all matching executables in PATH, not just first
CAVEATS
Which only searches PATH; it doesn't show shell builtins, aliases, or functions. Use type in bash or whence in zsh for comprehensive command lookup.
Some systems have different which implementations with varying options. The -a flag is common but not universal.
If a command isn't found, which typically exits with status 1 and produces no output (or an error message depending on implementation).


