The which command is used to locate and display the full path of executable files associated with the given command or program.
The syntax of the which command is as follows:
which [OPTIONS] NAME
Here are some commonly used options with which:
$ which vi ←Find the location of the "vi" command alias vi='vim' ←"vi" is aliased to "vim" /usr/bin/vim ←The location of the "vim" executable |
The which command is useful when you want to determine the full path of an executable, especially when multiple instances of a command with the same name exist in different directories listed in the "$PATH". It helps you identify which version of a command will be executed when you run it.
For more examples and information, you can refer to the provided link.