How to add a new SUDO user on Ubuntu16.04

Objective : Add a new SUDO user on Ubuntu UNIX system

SUDO users can run almost all the commands on a UNIX system which need elevated privileges. Doing all the server administration as root user is not advised at all due to security reasons. So, lets add a new SUDO user  :

1 . First step is to add a new user using adduser command. This command works well for ubuntu16.04 or any other versions of Ubuntu. For the purpose of this article, we’ll add a user tcdemo. If you are running below commands as root user, then you do not need to add sudo at the beginning of the commands but adding sudo will not make any difference either.

sudo adduser tcdemo

you will see below on the terminal:

Adding user `tcdemo' ...
Adding new group `tcdemo' (1003) ...
Adding new user `tcdemo' (1002) with group `tcdemo' ...
Creating home directory `/home/tcdemo' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:

Enter a new password for the user you just created and hit enter.

Retype new UNIX password:

Confirm the password you entered above. You will see below screen:

passwd: password updated successfully
Changing the user information for tcdemo
Enter the new value, or press ENTER for the default
 Full Name []: TechnologyCentral
 Room Number []: 
 Work Phone []: 
 Home Phone []: 
 Other []: 
Is the information correct? [Y/n]

Information above is optional and you can just hit enter for defaults. After these steps the new user is ready.

2. Next step is to add the newly created user to SUDO group using usermod command, so that user is able to execute commands needing elevated privileges. Run the below command

sudo usermod -aG sudo tcdemo

If you did not add any error message, then congratulations. You have added the new user to SUDO group.

3. Next step is to validate if the new user has been correctly added to SUDO group and able to execute SUDO commands. First we’ll switch to new user, using SU command

su - tcdemo

You will get prompt to enter password for new user

Password:

Confirm password and ENTER.

If the swith is successful, you should see something like this :

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Now, we will verify if the new user is able to run a sudo command. Easiest is to try an APT-GET update command, which needs SUDO rights. Execute command below

sudo apt-get update

Confirm SUDO password for the new user.

[sudo] password for tcdemo:

You will not need to confirm password for each command if they are being run back to back. If you do not execute any command for long time, you may be asked for sudo password again. This is a security feature.

Now, you should see the update instructions being executed on terminal if everything went fine.

add a new sudo user ubuntu

Conclusion:

We should always create a sudo user for server administration and not run the commands as root user for security reasons. This article gives us instructions about creating a new SUDO user on Ubuntu UNIX systems.

Other questions this article should help to answer:

  1. How to add a new user with SUDO rights on Ubuntu 16.04 .
  2. How to add an administrator on Ubuntu UNIX server .
  3. How to create a user who can execute SUDO commands on Ubuntu UNIX system .

Further reading:

  1.  More ubuntu resources at http://technology-central.org/category/ubuntu/
  2.  Ubuntu experts forum: https://askubuntu.com/

 

Updated: August 13, 2017 — 1:50 pm

Leave a Reply

Technology Central © 2014 - 2017 | Privacy Policy | Website Terms & Conditions