How to create a new sudo user on Ubuntu Linux server

I am a new Ubuntu Linux 16.04.xx LTS server user. How do I create a new sudo user on my server? How do I add a new user as sudoer file using the command line option on Ubuntu? In Linux (and Unix in general), there is a SuperUser named root. The root user can do anything and everything, and thus doing daily work as the root can be very dangerous. You could type a command incorrectly and destroy the system. The sudo command allows a permitted user to run a command as the superuser (root user) or another user, as specified by the security policy. Often the sudo used on servers to give admin permissions and privileges to ordinary users. In this quick tutorial, you will learn how to create a sudo user on Ubuntu.

Adblock detected 😱

My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon.

Steps to create a new sudo user on Ubuntu

First add the user, run: sudo adduser <UserNameHere>

Add the user to sudo group by typing the command in terminal for Ubuntu version 12.04 and above: sudo adduser <UserNameHere> sudo

More about admin and sudo group on Ubuntu server

The members of the admin group may gain root privileges. All members of group sudo run any command on Ubuntu server. So just add the user to the sudo group on Ubuntu server. The admin group has been deprecated since Ubuntu version 12.04 and above. Hence, no longer exists or used in Ubuntu 12.04 or above. The reason it works:# grep -B1 -i '^%sudo' /etc/sudoers OR$ sudo grep -B1 -i '^%sudo' /etc/sudoers Sample outputs:

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

How to print user account info

Verify new user and group membership with the [nicmd name=”id”]:$ id vivek Sample outputs:Fig.03: Show user and group information

How to test sudo access for vivek user account

Now user vivek can login using the ssh command command as follows:$ ssh vivek@server1.cyberciti.biz Verify that vivek can use sudo command:$ sudo cat /etc/sudoers The first time you use sudo command, you will be asked for the password of the vivek account. So type the vivek’s password to gain root access. Any command type with sudo should run with root privileges for vivek account. To gain root shell, enter:$ sudo -s Sample outputs:Fig.03: Testing sudo access for vivek user account

And there you have it. Allowing other users to run sudo on Ubuntu server and granting users administrator privileges.

This entry is 0 of 13 in the root user Tutorial series. Keep reading the rest of the series:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Your support makes a big difference:

I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft takes a lot of my time and hard work to produce. If everyone who reads nixCraft, who likes it, helps fund it, my future would be more secure. You can donate as little as $1 to support nixCraft: