How to add an user to sudoers and give him root permissions

Hello, friends. A question that many novice users don’t ask is how to add a user to sudoers. This is to give that new user the ability to use sudo and thus execute commands as root user.

The sudoers file

As we know, sudo is a utility of Unix-like operating systems, such as GNU/Linux, BSD, Mac OS X or macOS 11, that allows users to run programs with the security privileges of another user (usually the root user) securely. This definition provided by Wikipedia is one of the most accurate we can find.

sudo is installable on almost any Linux system, and in most of them it is already installed and configured for the initial user of the system. But what happens if we want to make another user use sudo as well? Well, we have to edit the sudoers file

The sudoers file located in /etc/ is the sudo configuration file. It specifies which users can use it and even how they can use it.

Although it is an ordinary file, it is convenient to edit it in a special way to improve the security of the tool.

Let’s go for it.

Add a user to sudoers and give him root permissions

For this post, I am going to go through the whole process, including user creation.

So, to create a user, you have to be a root user. Or the user must have sudo permissions.

For example:

sudo adduser

And during the command execution, you will be able to set name and password.

Now it is necessary to add it to the /etc/sudoers/ file, but we will edit it in the following way

sudo visudo

This will open the terminal and the editor.

Look for the line that goes like this


And below it add the new user with the same parameters. Suppose the new user is named daemon it would look like this.

daemon ALL=(ALL:ALL) ALL
How to add an user to sudoers
How to add an user to sudoers

Save the changes and close the editor.

It only remains to add the user to the sudo group. Although it is not necessary, it is advisable to do so.

sudo usermod -a -G sudo daemon

Now yes, the new user will be able to use sudo without problems and will have permissions to use it to obtain root access.

That’s all.


Sudo is an important tool for granting root permissions to users. It should be used with care and on servers or production environments it is not ideal to use it, but on home computers it can be a great help.

I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook