I need to runhave a program that is installed onin a custom directory under /opt/godi/sbin (a custom directory). IfTo make it easier to run it, I edited my bashrc to add thatsaid directory to my PATH, by adding the following line to my .bashrc filepath:
export PATH=$PATH:/opt/godi/bin:/opt/godi/sbin
thenThis works fine if I can trywant to run the command just fine (except that it fails because it needsprogram without sudo). However, whenif I try to userun it with sudo: it fails with a "command not found" error.
$ sudo godi_console
I get the following error
sudo: godi_console: command not found
Inspecting the PATH variable after using sudo reveals that its not including the same PATH I have as a normal user:
$ sudo sh
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Why is the PATH not the same? Am I doing something wrong? I'm on Debian Jessie and unfortunately, if it makes a difference.
One thing I cannot get around the issue bytried was to invoke /opt/godi/sbin/godi_console directly, passing sudo the the absolute linkpath to godi_consolethe executable. Unfortunatelly, that didn't help in this particular case because godi_console itself also depends on the PATH being correctly set.