Score:1

NOPASSWD option not working in sudoer file

cn flag

I know this has been asked before, but I tried answers from dozens of other posts, and nothing is working. I've also used this on other servers successfully, so I'm not sure what I'm doing wrong this time. Unfortunately, those servers are gone, so I can't use them as a reference.

I have a new Kubuntu 22.04 server, which I'm using to host my kid's Minecraft server. I'm trying to give an account permission to restart the systemd service without a password.

Steps:

  • I created a new sudo file using: sudo visudo /etc/sudoers.d/10-extras
  • This is the only file (aside from README) in that folder.
  • I've entered a single line: family ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart minecraft-bedrock.service
  • systemctl restart minecraft-bedrock still prompts for a password.
  • which systemctl shows /usr/bin/systemctl
  • I tried using family ALL=(ALL) NOPASSWD: ALL, with the same result.
  • I tried using family ALL=(ALL:ALL) NOPASSWD: ALL, with the same result.
  • I tried doing the above with my account, with the same result.
  • Out of curiosity, I tried the above on my VPS running Ubuntu 22.04 (using a different service), with the same result.
  • I tried all the syntax variations I've seen on other posts.
  • I've confirmed that @includedir /etc/sudoers.d is the last line /etc/sudoers.
  • I've tried doing all the above in the /etc/sudoers file directly.

Can someone point me in the right direction? I must be missing something painfully obvious.

Thanks!

PonJar avatar
in flag
On your system is `family` a user or a group? If it’s a group the entry should start `%family`
Jared avatar
cn flag
`family` is a user.
Score:0
cn flag

It started working, but I don't know why. All I did was change it to: family ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart *.

I changed it back to specifying the service file, and it continued working.

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.