How to Add a User to Sudoers Group in Ubuntu

Allowing the root user to login is a huge security risk so you should never do that. Instead, you can allow as many users as you need to have root access by adding them to the Sudoers group. This very short tutorial will show how to do that.

What is the sudo meaning?

sudo stands for superuser do. It is a linux command that allows the user to run commands as a super user or as other users.

Who can run sudo command in linux?

You can run sudo (add ‘sudo’ before your command to run it with elevated privileges) if your user is a member of the sudo Group.

How to add a user to sudo Group?

This is basically the same as adding the user to any other group. The line below will add the user called username to the Sudoers Group:

usermod -aG sudo username

How to test the user has sudo privileges?

Well, that’s easy. Just try to su (switch user) to root using sudo:

sudo su

Are you root now? Perfect!

This very short tutorial works for Ubuntu/Debian. If you are using Rocky Linux / CentOS, follow this article to add your user to the Sudoers Group which for some reason is not called sudo in Red Hat distributions but wheel.

Leave a Reply

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