0

Question

I have modified my /etc/sudoers (by visudo) to allow myself to execute any command with out a password but it didn't work.

All of similar questions don't work for me.

I still have to input my password when I'm using sudo.

My username and groups

❯ id -nG
guo network power libvirt autologin rfkill users video storage lp audio wheel sudo

System

❯ uname -a
Linux lead-inspiron 6.2.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 26 Feb 2023 03:39:23 +0000 x86_64 GNU/Linux

My /etc/sudoers

❯ sudo cat /etc/sudoers
root ALL=(ALL) NOPASSWD: ALL

guo ALL=(ALL) NOPASSWD: ALL
%wheel ALL=(ALL) NOPASSWD: ALL
%sudo ALL=(ALL) NOPASSWD: ALL
@includedir /etc/sudoers.d

I still couldn't sudo without inputing my password.

BTW, I'm not a native English speaker so i'm sorry for any mistakes.

1 Answer 1

2

With your /etc/sudoers, you should already have the user account guo authorized to run any command as any user without a password prompt, three times over: since guo is a member of groups wheel and sudo, the line guo ALL=(ALL) NOPASSWD: ALL will give guo exactly the same access as the line %wheel ALL=(ALL) NOPASSWD: ALL combined with the membership in the wheel group, or as the line %sudo ALL=(ALL) NOPASSWD: ALL combined with the membership in the sudo group.

But sudo is also configured to read the files in /etc/sudoers.d, and the last rule that matches the command will apply. So there must be some rule in /etc/sudoers.d/* that matches, and that rule apparently does not have the NOPASSWD: tag.

By running sudo -l as user guo (or sudo -l -U guo as any other user and providing a password if required) you can view all the sudo options and rules that will be applied to the user.

You should rearrange your sudoers rules so that one of the rules with the NOPASSWD: tag will be the last rule. For example:

root ALL=(ALL) NOPASSWD: ALL

@includedir /etc/sudoers.d
# guo ALL=(ALL) NOPASSWD: ALL  # not needed as guo is a member of both wheel and sudo groups
%wheel ALL=(ALL) NOPASSWD: ALL
%sudo ALL=(ALL) NOPASSWD: ALL

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .