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?

link|improve this question

61% accept rate
It might be as this because the http server is running in a chrooted environnement. – Maxwell Jan 12 '10 at 16:51
feedback

3 Answers

up vote 4 down vote accepted

You can use

$ which yourcommand

For example

$ which cat
   /bin/cat

You can also get the full path with

$ echo $PATH
   /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11

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.

link|improve this answer
feedback

In Bash, use type -a command.

link|improve this answer
feedback

You can use :

# which your_binary

or

# locate your_binary

To see where the binaries or located.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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