Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am calling a 'executable' on Linux. One way by console and another from PHP script. They both call other executable (i see it by version of file). So I need a way to display a path to executable that will be called when I try to run it. How to do this in Linux?

share|improve this question
It might be as this because the http server is running in a chrooted environnement. – Maxwell Jan 12 '10 at 16:51
up vote 5 down vote accepted

You can use

$ which yourcommand

For example

$ which cat

You can also get the full path with

$ echo $PATH

The : separate the paths that are used, in order or preference.

Note that the PATH can be different between users, so if your PHP script is executed with the www-data user for example, you have to check the PATH set for www-data. In general, it might be safer to specify the full path to the executable when you need to use a specific version of a program.

share|improve this answer

In Bash, use type -a command.

share|improve this answer

You can use :

# which your_binary


# locate your_binary

To see where the binaries or located.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.