Command referencewhich
which command (Linux / bash / sh / zsh)
What it does
Locate the executable selected from the current PATH. When people search for the which command linux path, they usually want which's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Locate the executable selected from the current PATH.
Syntax
which [OPTION]... COMMAND...
Common options
| Flag / option | Meaning |
|---|---|
| -a | Print all matching PATH entries. |
| --skip-alias | Ignore aliases where supported. |
| --skip-functions | Ignore shell functions where supported. |
| COMMAND | Name of an executable to locate. |
Practical examples
Locate Python
which python3
Prints the selected Python executable path.
All matches
which -a node
Shows every matching Node executable in PATH.
Test availability
which git >/dev/null && echo found
Checks whether Git resolves from PATH.
Linux ↔ Windows equivalent
Closest match: Get-Command (Windows / PowerShell). Discover commands, aliases, functions, scripts, and applications available to PowerShell.
Common mistakes
- Expecting which to explain aliases, functions, or shell builtins consistently; `command -V` is safer.
- Assuming the located executable is the version a script uses under a different PATH.
Related commands
- findWalk directory trees and select entries using tests and actions.
- exportMark shell variables for inheritance by child processes.
- Get-CommandDiscover commands, aliases, functions, scripts, and applications available to PowerShell.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- cdDisplay or change the current directory in Command Prompt.
FAQ
What does which do in Linux?
Locate the executable selected from the current PATH.
How do I use which from the terminal?
Start with `which [OPTION]... COMMAND...`, then choose only the options needed for the task.
What is a practical which example?
Try `which python3` — Prints the selected Python executable path.
Can I use which in a shell script?
Yes. which works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.