Ubuntu: Creating a sudo user

Steps to create a sudo user

Follow these steps to create a new user account in Ubuntu, and give it sudo access. If you already have a user account set up, skip to step .

Log in to your system as the root user

Be sure to replace IP 16.32.64.128 with your server’s IP address.

$ ssh root@16.32.64.128_

Create a new user account

Replace johndoe with the username you want to create.

$ adduser johndoe_

You will be prompted to set and confirm the new user password. Make sure that the password for the new account is as strong as possible.

Adding user `johndoe' ...
Adding new group `johndoe' (1001) ...
Adding new user `johndoe' (1001) with group `johndoe' ...
Creating home directory `/home/johndoe' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

Once you set the password the command will create a home directory for the user, copy several configuration files in the home directory and prompts you to set the new user’s information. If you want to leave all of this information blank just press ENTER to accept the defaults.

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] _

Add the new user to the sudo group

By default on Ubuntu systems, members of the group sudo are granted with sudo access. To add the user you created to the sudo group use the usermod command:

$ usermod -aG sudo username_

Test the sudo access

Switch to the newly created user:

$ su - username_

Use the sudo command to run the whoami command:

$ sudo whoami_

IF the user has sudo access then the output of the whoami command will be:

root

 

You can now log in to your Ubuntu server with this user account and use sudo to run administrative commands.

Leave a Reply

Your email address will not be published. Required fields are marked *