Ubuntu Add User to Sudoers

Ubuntu Add User to Sudoers

Add User to Sudoers in Ubuntu We’ll show you, how to create sudo user on Ubuntu 16.04. Sudo is a Linux-based program that allows privileged users to execute specific commands as the superuser or another system user. Adding users to the sudo group on Ubuntu 16.04 is a fairly easy task if you follow the tutorial below. Ubuntu Add User to Sudoers in five simple steps. Let’s get started.

1. Add User on Ubuntu

To be able to create a new system user and allow that user to execute commands as the superuser or another system user, you need to connect to your Linux server via SSH and run the command below. You should replace newuser with the actual name of the user you want to add to your system.

adduser newuser

Running the adduser command will create a new user account to the system according to the configuration information defined in the /etc/adduser.conf file. The adduser command also allows you to use one or more command line options such as specifying user’s home directory, user’s login shell, groups etc. Once you run the command you will see the following output on your screen:

# adduser newuser
Adding user `newuser' ...
Adding new group `newuser' (1001) ...
Adding new user `newuser' (1001) with group `newuser' ...
Creating home directory `/home/newuser' ...
Copying files from `/etc/skel' ...

2. Set Up a Strong Password

Next, you will be asked to enter a password for the newly created user:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for newuser

Make sure you are using a strong password for your account. Next step is to enter basic information about the user’s account such as name, phone number etc.

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]

Once you confirm that the information you entered is correct, the user account will be added and will be ready to use.

3. Add User to The sudo Group on Ubuntu

The whole point of this tutorial is to help you learn how to allow a certain system user to execute commands as the superuser or another system user. To achieve this you need to add the user to the sudo group. The members of this group have sudo privileges. Replace newuser with the name of your system user in the command below and execute it.

usermod -aG sudo newuser

4. Switch to the sudo user

Now, switch to that user:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
su - newuser

and run a command that a normal system user is not allowed to, such as the one below:

apt-get update && apt-get upgrade

The command above upgrades all the system software to the latest version and you will get the following output:

~$ apt-get update && apt-get upgrade
Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

5. Verify the sudo user

Try the same command now with sudo

sudo apt-get update && sudo apt-get upgrade

You will be prompted for the password. Enter the password you specified when creating the system user to proceed. If you have done everything correctly, the software index will be updated and all your system software will be upgraded.

Congratulations, now you have sudo user which you can use to manage your Ubuntu VPS.


Adding User to Sudoers in Ubuntu 16.04Of course, you don’t have to create a sudo user on Ubuntu, if you use one of our Ubuntu VPS Hosting services, in which case you can simply ask our expert Linux admins to create a sudo user on Ubuntu for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to create a sudo user on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

1 thought on “Ubuntu Add User to Sudoers”

  1. You have made the process much simpler man. Many people are directly installing software on root. They dont know the power of root and causing them loss when the use some unknown comments. Good article.

    Reply

Leave a Comment