Score:0

Sudoers NOPASSWD not working for specified commands

cn flag

I have the following entries in the sudoers file:

christian ALL=(root)NOPASSWD: /usr/sbin/shutdown
christian ALL=(root)NOPASSWD: /usr/bin/systemctl start mc

When running sudo shutdown -h now or sudo systemctl start mc, I still have to enter the password, even though I've set the NOPASSWD option for these commands. I am not sure why, because as far as I've read, this should be the correct syntax for it.

As far as I know I have to use an absolute path in the sudoers file, but I call it without. That might be the issue, but how do I make sudo workable with that then?

I'm using Ubuntu 20.04.6 LTS. What am I missing?

sa flag
does there need to be a space before NOPASSWD and possibly, no space after?
Apollo avatar
cn flag
This is it. I was not expecting this... Thank you.
Score:1
sa flag

NOPASSWD: comes before the command, not after the users. Try adding a space before NOPASSWD: and maybe removing the space after.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.