Reputation: 797
I have next result of command sudo -u www-data echo $PATH in terminal:
/home/denis/node-v0.12.0/bin:/home/denis/node-v0.12.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
I have next result in PHP if I run command echo `echo \$PATH`:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH in terminal and in PHP is different. I don't understand why.
Upvotes: 0
Views: 358
Reputation: 54505
Running the command literally as given
sudo -u www-data echo $PATH
the $PATH
is expanded by your shell before doing a sudo
(and show your $PATH
). However, if you quoted this properly, it could be deferred into the sudo'd user, and expose a different problem.
Unless you make special provision for this (an option to sudo
, which may/may not work), environment variables such as PATH
are reset to system defaults when using sudo
. For further discussion see
Upvotes: 2