How to Create a Sudo User in Ubuntu? [Step-by-Step]

The sudo user refers to a standard user with some elite powers. Moreover, A regular user has some limitations like executing some special operations or accessing some files from the root directory, etc. Sudo short of Super User DO let one do some of these privileged tasks. In this article, I will guide you through the procedure to create a sudo user in Ubuntu.

What is a Sudo User in Linux?

Sudo is the abbreviation of Super User DO. As the name suggests, A sudo user can be portrayed as the supreme user of the Linux-based machines. Because being a sudo user means having some distinctive powers compared to regular users. A sudo user can perform specialized tasks and access root-level contents.

Summary

You can easily create a sudo user in Ubuntu by following 4 simple steps and they are:

  • First, create a new user by using the adduser command.
  • Then, add the newly created user to the sudo group by using the usermod command.
  • Now, review whether the newly created user is actually being added to the sudo group.
  • Finally, look over the sudo access of the newly created sudo user.

Watch A Step by Step Guide to Create a Sudo User in Ubuntu

Steps of Creating a Sudo User in Ubuntu

In the following example, I will create a new sudo user named “simpsons” in Ubuntu. I have illustrated the full process in the following 4 easy steps.

Step 01: Create a New User in Ubuntu

You can create a new user from the terminal using the adduser command. Type the following command in the Ubuntu terminal.

adduser simpsons

Using the adduser command to create anew user in Ubuntu.

You have to be a root user to execute the adduser command. It can easily be done by prefixing the sudo command and then providing the user password.

sudo adduser simpsons

Using the adduser command with sudo to create anew user in Ubuntu.

Now, provide a password for the newly created user and retype it. Here, You can skip the data-filling step by pressing ENTER each time and finally press Y to confirm.

Steps of creating a new user.

Finally, you can check whether the user has been created or not by typing the following command.

getent passwd | grep simpsons

Checking whether the new user has been created.

Step 02: Add the New User to the Sudo Group in Ubuntu

By default, a new user is added to a group named on the username itself. However, most of the Linux distributions as well as Ubuntu contain a group named “sudo”. Adding a user to this sudo group means this user will now possess privileged powers.

Now, to add our newly created user “simpsons” to the sudo group type the following command on your Ubuntu Terminal.

sudo usermod -aG sudo simpsons

Adding the new user to the sudo group in Ubuntu.



Step 03: Confirm Whether the New User has been Added to the Sudo Group

You can check whether the newly created user “simpsons” is added to the sudo group or not. To do so type the following command:

groups simpsons

Checking whether the new user has been added to the sudo group.

Step 04: Check Sudo Access of the New User

Now that I have added my newly created user “simpsons” to the sudo group, Let’s check whether it can practice sudo access. First, switch to the “simpsons” user. To do so type the following command:

su - simpsons

Switching to new the newly created sudo user named "simpsons" in ubunru.

Then, execute the whoami command with sudo as a prefix

sudo whoami

Confirming wheher it is sudo user or not.

You can also check whether it can access the root directory by typing the following command:

sudo ls /root

Accesing the root folder with the newly created sudo user in ubuntu.



Check If a User is a Sudo User in Ubuntu

You can inspect whether a user is a sudo user or not by using the following process.

Steps to follow:

➊ First, open the Ubuntu Terminal.

➋ Type the following command in the command prompt:

sudo -l -U USERNAME

➌ Now, press the ENTER button.

Output:

In the following image, I have examined two users named “softeko” & “simpsons” respectively. Between them, softeko was not a sudo user but simpsons was.

Checkinh if a user is a sudo user or not.

List Sudo Rights For a User in Ubuntu

You can list the rights of a sudo user by simply following the below process.

Steps to follow:

➊ First, open the Ubuntu Terminal.

➋ Type the following command in the command prompt:

sudo -l

➌ Now, press the ENTER button.

Output:

In the following image, I have printed the rights of the sudo user named “simpsons” using the sudo command with the -l option.

Listing the rights of the sudo users.



Edit Sudoer File in Ubuntu

The sudo command can be modified by configuring the sudoer file located in the /etc directory. To edit the file you have to use the visudo command.

NB: Never edit the /etc/sudoer file with any normal text editors rather than the visudo command. Otherwise, it may break the sudo configuration.

Steps to follow:

➊ First, open the Ubuntu Terminal.

➋ Type the following command in the command prompt:

sudo visudo

➌ Now, press the ENTER button.

Output:

In the following image, you can see that the sudoer file has been opened in an editor (In Ubuntu it is nano). The main benefit of using the visudo command instead of using a normal text editor is that It will analyze the syntax while saving.

Configuring the sudo command by modifying the sudoer file.

Conclusion

The concept of sudo user emerged from the idea of stopping adversarial operations exerted on the root systems. However, to exercise privileged powers you might require the proficiency to create a sudo user in Ubuntu. Hope this quick and clear guide will help you to be privileged!

People Also Ask

What can a sudo user do?

A sudo user can act as the root user and exercise some privileged tasks compared to the regular user like accessing root files & folders.

Is a sudo user a root user?

No, there is a subtle difference between the two. A sudo user is privileged but not as much as the root user.

What is the difference between root and sudo user?

A sudo user can perform privileged tasks by adding sudo in the command every time. However, the root user is the supreme privileged one it doesn’t require to prefix sudo every time.

What are the 3 types of users in Linux?

There are primarily three kinds of users in Linux based on their permission privileges. They are 1) The Regular user, 2) The Root user & 3) The Service user.

Where is the sudo users list?

You can locate the list of sudo users in the /etc/sudoers file. You can also get the list of sudo users by checking the members of the sudo group. By running the following command getent groups sudo | cut -d -f4.

Why is it called sudo?

Since it is the abbreviation of super user do or substitute user do. It permits a user to act as the root (supreme) user or any other user,

Is sudo a vulnerability?

It depends on the level of privileges granted to the sudo user. If a sudo user has been granted too many root permissions, it may possess a risk to the system as it can alter system operations with its elevated power.

Is sudo a security risk?

The sudo user enjoys some raised security rights than the regular user. If misaligned or erroneous access is granted to a user it is a security concern otherwise not.

Why use sudo instead of root?

The root user can do anything on the system. This can be dangerous sometimes because as a root user one can delete important system files or may disrupt the security system of the machine. However, as a sudo user one will enjoy root privileges but with some restrictions that will maintain the soundness of the system. Hence, sudo is preferred to root.

What is sudo hack?

Despite being a general or regular user, one can easily execute all the commands in Linux as a superuser by using the sudo command. This is called the sudo hack.

Should sudo require a password?

Yes, sudo needs validation with the user password before executing a command, and the default timeout of this password is 15 minutes.

Relaed Articles

Rate this post
Md. Ashakul Islam Sowad

Md. Ashakul Islam Sowad

Hi, I am Md. Ashakul Islam Sowad from Dhaka, Bangladesh. I have completed my undergraduate degree in Biomedical Engineering from the Bangladesh University of Engineering and Technology (BUET). I love to watch football and play video games in my free time. Here, I am working as a Linux Content Developer Executive. Furthermore, as a Linux enthusiast, I am always learning new things about Linux-based systems and I’ll be sharing them here. Read Full Bio

We will be happy to hear your thoughts

Leave a reply

LinuxSimply
Logo