Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I'm trying to run an executable via the cli, like so:

phpunit DefaultTest

but i get "command not found" so i have to do:

/usr/lib/php/bin/phpunit DefaultTest

which works, how do i set it so i only have to use the executable name?

share|improve this question
up vote 1 down vote accepted

You'll have to append /usr/lib/php/bin to your $PATH environment variable. The best way to do this is to edit .bashrc or .profile and add /usr/lib/php/bin at the end of the $PATH like in the example below.



share|improve this answer
Your example adds it at the beginning. – Ignacio Vazquez-Abrams Sep 2 '10 at 4:27
great thanks, that worked. which is better .bashrc or .profile? – mononym Sep 2 '10 at 4:32
Ignacio: You're correct. You can do this instead, then: PATH="$PATH:/usr/lib/php/bin" :) – Christian Paredes Sep 2 '10 at 4:38
mononym: .profile will work just fine, though if you have a .bash_profile as well, then if you're using bash, bash will favor .bash_profile over .profile AFAIK. – Christian Paredes Sep 2 '10 at 4:39

You can also symlink to a place in the standard path. If you need to execute it outside of shell or if it had to be available for all users

sudo ln -s /usr/lib/php/bin/phpunit /usr/local/bin

/usr/local/bin is in the path and is the common location of user installed binaries, so its contents are available for execution systemwide.

share|improve this answer
Not really an option, symlinking creates a mess. Basically the only viable solution is altering $PATH – cpf Sep 2 '10 at 16:26
I didn't agree. symlinking beyond /usr/local is completly natural way to install system-wide and IMHO is safer than add directories to the global path. As I said for system wide setups. – theist Sep 3 '10 at 14:29

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.