Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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.

share|improve this answer

In Bash, use type -a command.

share|improve this answer

You can use :

# which your_binary

or

# locate your_binary

To see where the binaries or located.

share|improve this answer

Your Answer

 
discard

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.