The Unix ‘which’ command is a powerful tool designed to locate the exact path of executables in the system. When you input a command or a set of commands into the Unix shell, ‘which’ goes to work to find where these executable files are stored.
How Does ‘which’ Work? Upon executing the ‘which’ command with one or more arguments, it responds by displaying the full path to the executable file that corresponds to each argument. This feature is particularly useful for verifying which version of a command the shell will execute, based on the user’s environment and path settings.
Practical Usage of ‘which’ Here’s an example of how ‘which’ functions in a typical scenario:
which php /usr/bin/php
In this example, the ‘which’ command is used to locate the PHP executable. The output ‘/usr/bin/php’ is the absolute path where the PHP executable is stored.
Common Server Script/Binary Locations Below is a list of some of the most frequently used server scripts/binaries and their typical locations:
- PHP
- Location: /usr/bin/php
- MySQL
- Location: /usr/bin/mysql
- CURL
- Location: /usr/bin/curl
- WGET
- Location: /usr/bin/wget
- Bash Script
- Location: /usr/bin/bash
- PERL
- Location: /usr/bin/perl
- PYTHON
- Location: /usr/bin/python
These paths represent the standard locations for these executables on a Unix system. Knowing these paths is essential for system administration and scripting purposes, as it helps in efficiently managing and executing various server scripts and binaries.