18

I am creating a user in Ubuntu 14.04 using command adduser.

I want to give it sudo access. For doing this, I am consfused in between two ways.

First way is : If I add that user to sudo group using command usermod -aG sudo.

Second way is : If I edit the sudoers file using command visudo and add a line ALL=(ALL:ALL) ALL.

Please clear the confusion between these two.

2 Answers 2

19

sudo group is not special by itself. It has sudo access because (if) there's a line like this in the sudoers file:

%sudo   ALL=(ALL:ALL) ALL

So it's the file that really matters anyway.

4

The Ubuntu default /etc/sudoers configuration has two groups to allow sudo access. Members of these groups are allowed sudo access without requiring an edit to /etc/sudoers or the addition of a configuration file to /etc/sudoers.d.

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

The preferred way to do local configuration addition is to add a file to /etc/sudoers.d with the required configuration. This allows the default configuration to be updated automatically. Use visudo to at least verify these changes

You must log in to answer this question.

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