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.
Steps to Create 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. Go through the below steps, to see how it works.
- First launch a Ubuntu Terminal by pressing CTRL+ALT+T.
- Insert the following command to create a user:
- You have to be a root user to execute the adduser command. You can easily do this by the following command:
sudo adduser simpsons
Here the sudo command grants administrative privileges.
- 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:
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:
Here the groups command displays the user’s groups.
Step 04: Check Sudo Access of the New User
Now to check whether the user has sudo access, follow the below steps:
- Type the following command:
su - simpsonsHere
su -command switches current user to root.
- Then, execute the
- Check whether it can access the root directory by copying 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 command:
sudo -l -U USERNAME
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 typing the below command:
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.
Type the following command in the command prompt:
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.
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 do things like install or remove software, change system settings, and manage user accounts. This is because sudo users have the power to do things that regular users can’t, which helps keep the system safe by blocking access to important stuff.
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. While a root user has unrestricted access to all system resources and commands, a sudo user is a regular user account with the privilege to execute specific commands with superuser (root) privileges.
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 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. The term ‘sudo’ combines the first two letters of ‘superuser’ and ‘do’ to emphasize its primary function: executing commands with superuser privileges. This allows authorized users to perform administrative tasks, such as system configuration or software installation, while maintaining security by restricting access to only those who need elevated permissions.
Is sudo a vulnerability?
No, sudo is not a vulnerability itself. However, it is important to configure it in a way that restricts access to commands and users with higher privileges to reduce potential security risks. To ensure a secure system, it is essential to adhere to best practice access control and to regularly review and audit the configuration of sudo.
Is sudo a security risk?
Sudo can be a security risk if used incorrectly. It gives privileged access to users and if configured incorrectly or misused, it can result in unauthorized access or unintentional system changes. To limit potential security risks, it is important to configure properly, perform regular audits, and restrict sudo access to critical commands and users.
Why use sudo instead of root?
For greater security and accountability, we prefer Sudo over direct root access. With Sudo, users can execute specific commands with higher privileges, minimizing the chance of accidental system changes. Sudo also offers a centralized logging mechanism that allows administrators to monitor and review user activity, improving system auditability.
What is sudo hack?
A sudo hack is when someone tries to control systems using the ” sudo” command in Linux. It’s when someone takes advantage of a vulnerability to get higher privileges and run commands with admin rights. This is illegal and can lead to data leaks or system damage. To protect your system, make sure you take the right cybersecurity precautions and update your system regularly to reduce the risk of a sud 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. This helps prevent unauthorized access and strengthens overall system security.
- 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]