Grid Guide Topics
Table of Contents
The Sudo command grants administrator privileges. Generally, It is only available to the root user to the Normal users. In this guide, we are showing the easiest way to create a new user with sudo privileges on Ubuntu.
Steps to Create a New Sudo User
To Log in to your server as the root user enter the below command.
local$ ssh [email protected]_ip_address
If you want to add a new user to your system then use the adduser command. You have to put username of the user in place of username as shown below.
# adduser username
You have to set the password at the prompt and confirm it. Note that a strong password is highly recommended as shown below.
Follow the prompts if you want to set the new user’s information. And you have to accept the defaults to leave all of this information.
To add the user to the sudo group use the below command.
$ usermod -aG sudo username
In Ubuntu, By default, the members of the sudo group have sudo privileges.
If you want to test sudo access to the new user account then test it using below command.
# su - username
Now you are a new user, you can test that you can use sudo by adding sudo to the command like this.
username$ sudo command_to_run
For example, If you want to list the contents of the /root directory, which is usually accessible to the root user.
username$ sudo ls -la /root
If you use sudo in a session for the first time, then you will be prompted to a password of the user account. Enter the password to proceed further.
If the user entered the correct password and he is an inexact group then that user will have sudo with root privileges.
Now the user has sudo privileges.