Score:2

Selectively enable sudo without password

jo flag

On my Ubuntu system I followed the instructions for enabling sudo without a password.

It is working well, or should I say too well.

I have a couple of users, say userA and userB, who have been added to the sudo group.

sudo usermod -aG sudo userA
sudo usermod -aG sudo userB

I did sudo visudo and I added the following line at the bottom (i.e. the very last line):
userA ALL=(ALL) NOPASSWD: ALL

However, I am finding that sudo without password is enabled for both userA and userB.


Question: How can I enable sudo without password for userA, but not userB?

cocomac avatar
cn flag
Does this answer your question? [Enable passwordless sudo as a specific user](https://askubuntu.com/questions/239432/enable-passwordless-sudo-as-a-specific-user)
Score:0
it flag

If, as you have done, the users are in the sudo group, they'll match the more general %sudo pattern in the sudoers file, and never see the UserA or UserB lines.

If you want fine-grained control, remove both UserA and UserB from the sudo group.

sudo deluser --system UserA sudo
sudo deluser --system UserB sudo

Read man sudoers deluser.

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.