which Linux Command
Shows the full path of the executable that would run for a given command.
What does which do?
Shows the full path of the executable that would run for a given command.
Syntax
which commandPractical example
which python3Questions about which
How do I find the path of a command?
Use `which commandname` to see the full path of the executable. For example, `which python3` might show `/usr/bin/python3`.
How do I check if a command exists?
Use `which commandname` and check the exit code. If it returns a path, the command exists. If not, it is not installed.
How do I see all versions of a command?
Use `which -a commandname` to show all locations in the PATH where the command is found.
What is the difference between which and whereis?
`which` shows the executable path. `whereis` shows the binary, source files, and manual page locations.
How do I see what command an alias refers to?
Use `which commandname` to see the underlying command for an alias, or `type commandname` for more detailed information.
How do I check which Python is the default?
Use `which python` or `which python3` to see which Python interpreter is used when you run the command.
How do I find where a command is installed?
Use `which commandname` for the executable path, or `whereis commandname` for binary, source, and man page locations.
How do I see if a command is an alias?
Use `type commandname` which shows if the command is an alias, builtin, function, or external program.
Related Search Commands
locateQuickly finds files by name using a pre-built database (run updatedb to refresh).
whereisLocates the binary, source, and manual page files for a command.
grepSearches for patterns (text or regex) inside files and prints matching lines.
typeDisplays how a command name would be interpreted (alias, builtin, external, etc.).
findSearches for files and directories in a directory hierarchy by name, type, size, etc.
awkPowerful text processing language for pattern scanning and data extraction.