0

I want to use When Gnome Scheduler to run this:

sudo service fancontrol start 

As "sudo" needs a password, how can I add it into the command, so that it can be run successfully? Each time Mint resumes after suspension, it needs to be run again.

2

Instead of wondering how to get a password into a script I'd suggest modifying sudoers (or, even better [because cleaner], adding a separate file for this purpose to /etc/sudoers.d/).

Something like (assuming matthew's your username):

cat /etc/sudoers.d/fancontrol
matthew    ALL=NOPASSWD: /usr/sbin/service fancontrol start

Make sure it has the right permissions, and best to use visudo to edit it (that makes sure you don't have syntax errors in the file).

chmod 0440 /etc/sudoers.d/fancontrol
  • Do you mean using the command "chmod 0440 /etc/sudoers.d/fancontrol" on When Gnome Scheduler after adding the separate file "fancontrol" into the folder "/etc/sudoers.d/"? – Matthew Wai Feb 9 at 9:35
  • I added the separate file "fancontrol" into "/etc/sudoers.d/". When I run "sudo service fancontrol start", it says the following: ">>> /etc/sudoers.d/fancontrol: syntax error near line 1 <<< sudo: parse error in /etc/sudoers.d/fancontrol near line 1 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin". – Matthew Wai Feb 9 at 12:09
  • I tried to use "sudo nemo /" to delete "fancontrol", but I got the same error. How can I delete it? – Matthew Wai Feb 9 at 12:12
  • Actually, I fail to run any "sudo" command. What should I do? – Matthew Wai Feb 9 at 12:17
  • I just booted from a Mint Live SD card. I selected "Show Hidden Files" and went to "/etc/sudoers.d/" on the HDD, but "fancontrol" was not there. I am now using Mint installed on the HDD, and "fancontrol" is still in "/etc/sudoers.d/". Why can't I find it via Mint Live? How can I delete it? – Matthew Wai Feb 9 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.