I am calling an 'executable' on Linux. One way by console and another from a PHP script. They both call other executables (I see it by the version of the file). So I need a way to display a path to the executable that will be called when I try to run it. How do I do this on Linux?
Asked
Active
Viewed 3,787 times
1
-
It might be as this because the http server is running in a chrooted environnement. – Maxwell Jan 12 '10 at 16:51
3 Answers
6
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.

raphink
- 11,987
- 6
- 37
- 48
1
You can use
# which your_binary
or
# locate your_binary
to see where the binaries or located.

Peter Mortensen
- 2,318
- 5
- 23
- 24

Maxwell
- 5,076
- 1
- 26
- 31