Whether you just want to create a new user on your Ubuntu OS for yourself, or you want to let someone else use your system with all the privileges like a root user, there comes the use of the Sudo. A sudo user will be able to use all the functions and features of the OS just like a root user do. In most of the cases, performing operations as a root user is not recommended. So, as soon as you install the Ubuntu OS on your PC or server, it is always recommended to create a Sudo user and perform the required operations.
In this guide, we are going to familiarize with the term sudo
and how to create a sudo user. Without further due, let’s begin the article.
What is a Sudo user?
A sudo user is a user who has the administrative privileges that are only available for the root user by default. As a sudo user, you will be able to perform almost any actions on the OS with all the privileges that a root user has. Sudo performs on a per-command basis and is not similar to the shell that you are using. You will have to put sudo command in front of each line that you want to run with the administrative privileges. This is the quick explanation of the sudo user in Ubuntu.
How to create a Sudo user?
Now, you know what is a sudo user. It is the time to create one. Follow the below-given steps to create a sudo user in Ubuntu.
- Log in to the server as the root user by typing
ssh root@ip_address_of_the_server
. - Type
adduser username
. Be sure to replace the “username” with your preferred user name. - It will ask you to set a UNIX password for the user. Provide a password, retype it when asked. and you will receive a message saying “password updated successfully.”
Set password prompts:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully - Next, you will be asked a few more details regarding the user you just created. You could either fill them or just skip them by pressing “Enter.” Finally, confirm the given details by typing “Y” and press “Enter.”
User information prompts:
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] - Now you have successfully created a user in Ubuntu. Now it is the time to add the created user to the sudo group. For this, type the following in the command line. Be sure to replace “username” with the correct username.
usermod -aG sudo username
- You have successfully added the user to the sudo group. If you want to test it, just switch the user by typing
su - username
and try to run a command that is only available for the root user. For example, try runningsudo ls -la /root
. It will ask you for the sudo user password the first time you are trying to run a sudo command. Provide it when asked, and if the root directory is listed, you are now a sudo user.