How to add User to sudoers in Ubuntu

How to add User to sudoers in Ubuntu

This content is special for those who are new to Ubuntu. By following this blog post, you can execute any command with ease. In this tutorial, we will understand how to add a user to sudoers in Ubuntu with simple steps. Before starting, let’s get some basic information about sudoers.

Sudoers

Sudoers is one of the Linux user groups where users can perform read, write, and execute any packages with sudo command in Ubuntu operating system. This command helps you to perform any root user package execution process without logging in to the root account in the terminal. For example, I am a new Ubuntu user and I am currently working as a default Ubuntu user. But I need a new user account for my brother so that he can access his own files and software on that user. To add a new user in Ubuntu operating system, follow the given steps.

Add user in Ubuntu

To add a new user in Ubuntu operating system, open the terminal on your Ubuntu system and log in as a root user with “sudo su” command. Then, the user can automatically log in to the root session. After completing this, you can follow the given command to add a new user on Ubuntu system.

sudo adduser "$USERNAME"

Now, you can put the following command to add a new user in your Ubuntu system. Replace the value “$USERNAME” with the username who can be added to your system. After doing this, you need to put in more information like your name, phone number, and set the password.

For example, if I need to add a new user “testuser” on my system, then I need to follow the given command:

sudo adduser testuser
add test user ubuntu

After putting this command, I need to add some more information and set the password to add the new user successfully on my Ubuntu operating system. To access this user over SSH or terminal, I can put the following command:

su testuser

I can successfully access this user, but when I try to install any software with sudo command, I get the following error:

user permision error in ubuntu

From this error, this user is not able to install any software because this user has no sudoers permission from the root user. Now, we can start the process for this.

Add user to sudoers in Ubuntu

To add a user to sudoers in Ubuntu, first, we need to move to the root user in the terminal. After doing this, now you can put the following command:

sudo usermod -a -G sudo "$USERNAME"

After doing this command, the new user is able to perform any task on the Ubuntu system. Now, we can apply and test the new user on my system.

sudo usermod -a -G sudo testuser
allow user sudo permision

After applying these changes, you can see that the new user is ready to install any software and perform any task on the Ubuntu system.

sudo permision successfully Applyed to test user

I hope you find this blog post useful. If you agree with me, please subscribe to my blog to get notifications for more blog posts like this on your device.