Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 25237  / 2 Years ago, sat, april 9, 2022, 6:06:49

Possible Duplicate:

How to run an application using sudo without a password?






I've made a script that preforms various system tasks, that I run regularly, but I have to use sudo to run the script, despite the fact that I own it because it runs root privileged commands. How can I add make sudo let me run this one file without having to enter my password every time I run it?



I know that there are questions regarding running commands without a password, but I wasn't able to find one on running a file without a password.



I am aware of the security risks, but I'm at home on a computer that I trust.



I added john ALL = NOPASSWD: /home/john/.script/hibernate.sh to my /etc/sudoers but when running the command sudo sh /home/john/.script/hibernate.sh it still prompts me for my password...


More From » files

 Answers
3

Use visudo for a safe editing environment to edit the sudoers file. This script is a wrapper around vi that also does syntax checking when you save the file and won't let you overwrite a valid sudoers file with an invalid one.



Add a line like this:



username ALL= NOPASSWD: /path/to/your/script


The "ALL=" bears some elaboration, it specifies that the permission is granted when the user in question is logged in from any location, locally (console or terminal) or remotely (ssh, etc).


[#34941] Sunday, April 10, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
splenueak

Total Points: 448
Total Questions: 118
Total Answers: 110

Location: Vanuatu
Member since Mon, Oct 3, 2022
2 Years ago
splenueak questions
Tue, Aug 24, 21, 09:07, 3 Years ago
Sat, Apr 23, 22, 15:14, 2 Years ago
Thu, Jun 10, 21, 17:43, 3 Years ago
Mon, Sep 20, 21, 15:19, 3 Years ago
;