1

I am trying to add NOPASSWD option for existing user who belongs to the sudo group and have admin rights. I added this line in sudoers file:

max     ALL=(ALL:ALL) NOPASSWD: ALL

But it still ask me for password when i try to execute command with sudo.

heemayl
  • 91,753
user1800997
  • 377
  • 1
  • 4
  • 17

1 Answers1

8

The sudoers file is parsed line by line and the last rule prevails for a given user.

So, you need to add this rule after all other rules applicable for the given user to have this in effect.

For example, if the user max belongs to sudo group, then the following won't have desired result:

max     ALL=(ALL:ALL) NOPASSWD: ALL
%sudo   ALL=(ALL:ALL) ALL

Reverse the order to get max passwordless sudo access:

%sudo   ALL=(ALL:ALL) ALL
max     ALL=(ALL:ALL) NOPASSWD: ALL
heemayl
  • 91,753
  • Or better yet, a new file in /etc/sudoers.d/ (which are parsed at the end of the main file in default configuration) – Oli Aug 10 '16 at 12:19
  • Note to future readers: there are restrictions on what you can and cannot name files in the /etc/sudoers.d/ folder. https://stackoverflow.com/a/71851251/8859073 – maples Apr 13 '22 at 02:47