which — Find the Location of a Command

The which command shows the path of the executable that will run when you type a command name. It is useful when multiple versions of a tool may be installed.

Basic use

which python
which bash
which gcc

If the command is found in your PATH, which prints the full path. If nothing is printed, the command may not be installed or may not be in your current PATH.

Check all matches

which -a python

This can help when troubleshooting path order or unexpected command versions.

Leave a Comment