1

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?

Peter Mortensen
  • 2,318
  • 5
  • 23
  • 24
Tom Smykowski
  • 1,125
  • 5
  • 19
  • 27

3 Answers3

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
4

In Bash, use type -a command.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
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