How do you make the scripts in /home/$user/bin accessible using sudo? as in:
sudo $NameOfScript
in using Ubuntu 12.04
How do you make the scripts in /home/$user/bin accessible using sudo? as in:
sudo $NameOfScript
in using Ubuntu 12.04
Environment variables are reset for sudo
for security reasons, including the PATH
variable that controls which programs you can run conveniently at a prompt.
However, you can bypass this limitation by specifying the absolute or relative path to the command you want to use. In your example:
sudo /home/$user/bin/$NameOfScript
As compared to the approach of changing PATH
, this preserves the security precautions around root's environment variables while still allowing you to run whatever program you want with sudo
.