which command in Linux with examples
which command in Linux is a command which is used to locate the executable file associated with the given command by searching it in the path environment variable. It has 3 return status as follows:
- 0 : If all specified commands are found and executable.
- 1 : If one or more specified commands is nonexistent or not executable.
- 2 : If an invalid option is specified.
which [filename1] [filename2] ...
- which -a : This option print all matching pathnames of each argument.
- info which : It displays help information.