Locate Executables in PATH
which locates the executable file associated with a given command by searching through the directories listed in the PATH environment variable. It shows which version of a command will be executed when you type it in the shell. This is particularly useful when multiple versions of a command exist on the system.
Shows the full path to the python3 executable that would be executed.
Searches for multiple commands at once, displaying the path for each.
The -a option displays all matching executables in PATH, not just the first one found.
Returns no output when command is not found in PATH. Exit status is non-zero (failure).
Common pattern in scripts to verify a command exists before attempting to use it.
The cd command returns nothing because it's a shell built-in, not an external executable. ls is an external command and shows its path.
Combines which with ls to show if the command is a symbolic link and where it points.
Shows difference between which (PATH only) and whereis (multiple file types).
Shows which version takes priority based on PATH order. First match is executed.
The type command is more comprehensive than which as it shows builtins, aliases, functions, and executables.
-a - Show all matching executables in PATH-s - Silent mode, only return exit statuscommand -v - POSIX-compliant alternativetype - Shows all command types (builtins, aliases, etc.)whereis - Finds binaries, source, and man pagestype instead of which in scripts for better portability and to detect shell builtins, aliases, and functions.