Skip to main content
deleted 71 characters in body
Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Dodo I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

$ sudo /path/to/myscript 

works without password, but do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

Thanks.

added 2 characters in body
Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

Thanks.

added 72 characters in body
Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root. But, but the problem is that it still needs password.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root. But the problem is that it still needs password.

$ sudo /path/to/myscript 

works without password.

Thanks.

For a line that I added to /etc/sudoers, for example:

t ALL=(ALL) NOPASSWD: /path/to/myscript 

/path/to is in PATH of the current user t, but not in PATH of root.

Do I need to specify the pathname of the script every time I run the script with sudo?

$ sudo myscript [sudo] password for t: sudo: changeCpuFreq.sh: command not found 

doesn't work even with password, because myscript's path isn't in PATH of root.

$ sudo -E env "PATH=$PATH" myscript [sudo] password for t: 

works with password, because PATH of t is copied to that of root, but the problem is that it still needs password.

$ sudo /path/to/myscript 

works without password, but the problem is that it needs to specify the pathname to the script.

Thanks.

Source Link
Tim
  • 106.9k
  • 234
  • 651
  • 1.1k
Loading