Skip to main content

Command referencewhich

which command (Linux / bash / sh / zsh)

Linuxbashshzshfilebeginner

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 / optionMeaning
-aPrint all matching PATH entries.
--skip-aliasIgnore aliases where supported.
--skip-functionsIgnore shell functions where supported.
COMMANDName 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.

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.