Adding a group to Sudoers

Recently on our VPS servers there has been no admin group on a default Ubuntu install. Here is the solution.

Add an admin group to the Ubuntu install.

[cc lang=’bash’ ]addgroup admin[/cc]

Now you will need to add any users you want to have root privileges to the admin group.

[cc lang=’bash’ ]adduser cbrown admin[/cc]

Now go to the edit the sudoers file to include the admin group.

[cc lang=’bash’ ]nano /etc/sudoers[/cc]

and insert the following at the bottom of the file.

[cc lang=’bash’ ]# Members of the admin group may gain root privileges[/cc]
[cc lang=’bash’ ]%admin ALL=(ALL) ALL[/cc]

Once this is complete, any user you have placed in the admin group will now have root permissions.  Give this access wisely and only to people you trust!

Other User/Group Commands

To add a user.

[cc lang=’bash’ ]sudo adduser cbrown[/cc]

If you want to create a user and give them a home directory other than the default.

[cc lang=’bash’ ]sudo adduser –home /home/cbrown cbrown[/cc]

If you want to delete a user.

[cc lang=’bash’ ]sudo deluser  cbrown[/cc]

Delete a user and remove their home directory.

[cc lang=’bash’ ]sudo deluser –remove-home cbrown[/cc]

To delete a group.

[cc lang=’bash’ ]sudo delgroup GROUPNAME[/cc]

Remove user from a group.

[cc lang=’bash’ ]sudo deluser john accounts[/cc]

Leave a Reply

Your email address will not be published. Required fields are marked *