Site icon Thetechhacker

How to Create a Sudo User on Ubuntu

How to create a sudo user in Ubuntu

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 sudoand 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.

If you are trying to create a sudo user on your PC, you just have to access your command shell and skip the first step. If you are on a server (which is the most common case) follow these steps.
  1. Log in to the server as the root user by typing ssh root@ip_address_of_the_server.
  2. Type adduser username. Be sure to replace the “username” with your preferred user name.
  3. 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
  4. 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]
  5. 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
  6. You have successfully added the user to the sudo group. If you want to test it, just switch the user by typing su - usernameand try to run a command that is only available for the root user. For example, try running sudo 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.
Exit mobile version