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
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
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.
Finally, you can check whether the user has been created or not by typing the following command.
getent passwd | grep simpsons
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
- How to Create a Jenkins User on Ubuntu? [2 Methods]
- How to Create MySQL User in Ubuntu? [2 Cases]
- Create User Without Home Directory in Ubuntu in Just 3 Steps
- How to Create a User in Docker Container Without Docker File?
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
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
Then, execute the whoami command with sudo as a prefix
sudo whoami
You can also check whether it can access the root directory by typing the following command:
sudo ls /root
- How to Create an FTP User in Ubuntu? [Step-by-Step]
- Create a New SFTP User in Ubuntu with a New SSH Key
- How to Create Group and Add User in Ubuntu? [2 Cases]
- Create FTP User for Specific Directory in Ubuntu [4 Steps]
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.
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.
- How to Create Multiple Users in Linux? [2 Methods]
- Create a User in Ubuntu as Read-Only Access to Log Folder
- How to Create User Account in Ubuntu with Public Key
- Create A User in Ubuntu that Runs a Script and Logs Out [4 Steps]
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.
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.
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?
Is a sudo user a root user?
What is the difference between root and sudo user?
What are the 3 types of users in Linux?
Where is the sudo users list?
Why is it called sudo?
Is sudo a vulnerability?
Is sudo a security risk?
Why use sudo instead of root?
What is sudo hack?
Should sudo require a password?
Relaed Articles
- How to Create User and Add to Sudo in Ubuntu? [2 Methods]
- 2 Ways to Create a User With Access to a Drive in Ubuntu
- How to Create a New User in Ubuntu by GUI? [Step-by-Step]
- 2 Ways to Create User Account in Ubuntu Using Terminal
- How to Create Home Directory for Existing User in Ubuntu
- Create User with UID and GID in Ubuntu? [3 Scenarios]
- How to Create a Root User in Ubuntu [Step-by-Step]