I have the following command:
sudo service cron start
When I type it into the terminal, it asks me for a password, just as it should. But I need for users (or if all users aren't possible, then at least my user) to be able to run this specific command without needing to put in any passwords. I googled around, even looked at similar questions here and found about visudo, so I gave it a try, and put this into the sudo config file, which I accessed through visudo.
mike ALL = NOPASSWD: /usr/sbin/service cron start
But it had no effect at all, I still get asked for a password when I try to do sudo service cron start
, or even sudo /usr/sbin/service cron start
sudo -l:
Matching Defaults entries for mike on bolt:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User mike may run the following commands on bolt:
(root) NOPASSWD: /usr/sbin/service cron start
(ALL : ALL) ALL
So what am I doing wrong here?
sudoers
did you put this? Edit your post to add the output ofsudo -l
, please. – muru Jul 29 '21 at 08:21sudoers
file. You can see a later rule ((ALL : ALL) ALL
) is getting precedence here. – muru Jul 29 '21 at 08:51root
-level commands without a password in WSL that most "normal" Ubuntu users wouldn't know about. – NotTheDr01ds Jul 29 '21 at 14:55