Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

which shows my local install of php

and whereis php shows the global php install (shared env)

share|improve this question
up vote 4 down vote accepted

The two programs have different ideas about where to look. They can also be implemented in different ways on different systems. On mine, whereis is a binary executable and which is a Bourne shell script.

If you'd like yet other opinions on where something is, try these:

type -a php


locate php

From the whereis man page:

whereis has a hard-coded path, so may not always find what you’re looking for.

From the which man page:

which returns the pathnames of the files which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments.

So whereis searches a hard-coded path, which uses the $PATH variable, locate uses a database of the (by default) whole file system, and type, which is a Bash builtin, looks in the $PATH, the builtins, aliases and function definitions.

I use type and locate primarily and only very rarely use the other two since they are relatively limited in capability.

Oh, and in order to answer your question, which, because it searches $PATH, is more likely to show you the location which will actually run if you type the command "php". And type is probably going to be even better in cases where you have aliases or functions of the same name since they are executed preferentially over the $PATH location. Note that all of this is system dependent and also dependent on the shell that you are using (my assumption is that it is Bash). On my system, using Bash, the order is functions, aliases, builtins, then $PATH (in the order in which directories are listed there). Compare the output of these various commands to:

echo $PATH
share|improve this answer
thanks for the break down – qodeninja Sep 28 '09 at 6:18

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.