1

I have a fresh install of Ubuntu 18.04

I made the mistake of editing /etc/sudoers with "vim" first instead of using "visudo". Therefore when I was doing "sudo command" it kept asking for my password. Then I tried to do "sudo visudo", retyped the line for my user, saved it. But it keeps asking for my password whenever I use "sudo command". What could be wrong?

System output:

$ grep alain /etc/sudoers
  alain ALL=(ALL) NOPASSWD: ALL

$ sudo -l

  User alain may run the following commands on wscg4:
  (ALL) NOPASSWD: ALL
  (ALL : ALL) ALL
2

Moving the user's line to an external file fixed it:

$ sudo visudo -f /etc/sudoers.d/myOverrides

1
  • The user (alain) is probably also in the sudo group. And in the sudoers file you first define user privilege specification and then allow members of group sudo to execute any command. And so override your NOPASSWD. By putting it in the sudoers.d folder, you override it again. Dec 1 '20 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.