Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I add more users to the "sudoers" file?

share|improve this question
add comment

4 Answers 4

up vote 26 down vote accepted

Just edit the file /etc/sudoers.

But you are supped to use /usr/sbin/visudo as your editor, since that will to some sanity checks before you exit.

So that would be:

sudo /usr/sbin/visudo

Here are some links that could be useful:

share|improve this answer
    
Then how do I save the file –  D'Arvit Sep 11 '09 at 8:55
    
Never mind, realized it happened on the exit. –  D'Arvit Sep 11 '09 at 8:59
    
+1. On some systems, the /etc/sudoers is readonly, and editiion is forced through the visudo command. –  Laurent Etiemble Dec 16 '09 at 8:53
    
If you have an /etc/sudoers.d directory, don't modify the /etc/sudoers file. Instead, put the entry in its own file in that directory. –  David Schwartz Feb 6 '13 at 6:48
add comment

My preferred method is to add them to the admin (now sudo, since Ubuntu 10.04) group.

In Ubuntu Linux, the sudo group can run sudo and it is easy to add someone to that group:

usermod -a -G sudo username

Your mileage may vary with other distros, however, someone thought the group method made more sense than the sudoers file getting itself updatified. Less room for getting it wrong and locking everyone out of being superuser seems to be the reason.

share|improve this answer
1  
admin group doesn't exist since at least Ubuntu 10.04 –  Artem Pakk Jun 29 '11 at 11:01
add comment

Just edit your sudoers file

sudo visudo -f /etc/sudoers

and add the username like 'uk' without quotes

username ALL = (ALL)ALL

Save and exit would give the access.

share|improve this answer
6  
Like Johan says, visudo should be used to edit the sudoers file. A borked sudo file can lead to a world of avoidable pain. en.wikipedia.org/wiki/Visudo –  nagul Sep 11 '09 at 9:04
3  
Why did you add quotes to your example, then? –  grawity Sep 11 '09 at 10:15
add comment

visudo opens the sudoers file and has samples for simple situations.

You may have to add option 'NOPASSWD' if user scripts would use commands/binaries which can be run only with "sudo", e.g.

ALL=(ALL) NOPASSWD: ALL

It is also possible to specify group instead of user name. So you need not list each and every user, e.g.

%users  localhost=/sbin/shutdown -h now
share|improve this answer
1  
Beware that NOPASSWD may be a security risk. –  Johan Nov 4 '09 at 5:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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