How do I add a user to the sudoers file? [closed]

I already know that I should:

  • run visudo
  • be logged in as root

But then what changes should I make to the sudoers file?

p.s. The question got 'down-voted'. Is this a bad question?! I looked at man sudoers, and there are several pages of explanation of everything to do with the sudoers file, most of it in Extended Backus-Naur Form. I want to know something much more specific and I don't have 3 hours to waste finding out how. In other words, I want a simple example for someone with not that much experience.


It's a bad question because you've given no information about what you're trying to achieve. Someone could say run "sudo visudo", append "#username" to the bottom of the file, save, done.

Do you want the user to be able run commands as root? With or without a password? The sudoers file is both flexible and complicated.

For simply allowing the user to run commands as root you would usually add them to a predefined group that is already in the file such as as "admin" or "sudo".

I.E:

usermod -a -G admin username