2

How do you make the scripts in /home/$user/bin accessible using sudo? as in:

sudo $NameOfScript

in using Ubuntu 12.04

John
  • 691
  • and http://askubuntu.com/questions/110028/added-folders-to-path-cannot-be-found-using-sudo – Panther Jun 07 '13 at 20:14
  • 1
    @bodhi.zazen I don't think this is a duplicate. I think that the OP want to know how to run that script with administrative privileges instead of user privileges. – Radu Rădeanu Jun 08 '13 at 07:41
  • yes i want to know how to make it is it requires sudo – John Jun 10 '13 at 01:06

1 Answers1

1

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.

Paul
  • 7,007
  • 3
  • 23
  • 30