Ubuntu – Some programs not found when used with sudo

command linesudo

I just installed go to /usr/local/go, and in ~/.bashrc added this line:

export PATH=$PATH:/usr/local/go/bin

Now go works from the command line, but sudo go gives me:

$ sudo go
sudo: go: command not found
~
$ sudo echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/benjamin/algs4/bin:/usr/local/go/bin

Best Answer

sudo command has env_keep and env_reset parameters in sudoers file.

You have to either edit your env_keep setting or use sudo -E.

Related Question