Online Linux Terminal Logo
OnlineLinuxTerminal
NavigationCLI Reference

$which

Locate the executable binary path of a command in system PATH.

Syntax DefinitionPOSIX standard
which [OPTIONS] [COMMAND...]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `which` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How which Works

`which` searches the directories listed in your `$PATH` environment variable to find and display the absolute location of an executable binary file.

Common Flags & Command Options

Flag / OptionDescription
-aPrint all matching pathnames of each argument across PATH.

Practical Real-World Examples

Example #1Find where python3 or grep is installed
which grep python3

Outputs the binary paths in /usr/bin or /bin.

Sample Output:
/usr/bin/grep /usr/bin/python3

Frequently Asked Questions

What is the difference between which and whereis?

`which` locates only the executable binary in `$PATH`, while `whereis` also locates source files and man documentation pages.