How to create a Sudo user on Ubuntu

Normal users can acquire administrator privileges which is usually held by the root user, via the sudo command.  In this short article, you will find an easy way to create a powerful new user who will have sudo access on Ubuntu. This will be achieved without modifying the server’s Ubuntu sudoers file. You will then be able to execute commands which require administrator privileges without logging in as a root user.

Read: ‘usermod’command usage in Ubuntu/Debian : a beginner’s guide

Simple steps to create a new sudo user

1.Log in as the root user to your system:

ssh root@server_ip_address

Read: How to change the hostname in Ubuntu

2. New user account creation

In order to add a new user to the system, use the adduser command.Make sure to replace the username below with the new username to be created.

sudo adduser username

You will then be prompted in order to confirm the new user password, and other credentials (you can leave them blank by pressing ENTER to accept the default) . Make sure to provide a complex password that can not be hacked.

You may be interested to read: The Sudoers File in Ubuntu

Create sudo user ubuntu

After setting the password, the command above will set up a home folder for the new user as well as copy various configuration files in the home folder.

Read: How to fix Broken Pipe Error in Linux

3- Adding the new user to the sudo group

Sudo access privilege is granted to all members of the sudo group by default on Ubuntu.In order to add the new user you have created to the sudo group, you can use the usermod command as shown below :

usermod -aG amin_net2

Add user to sudoers Debian

Read: How to switch users on Linux/Ubuntu

4-Sudo access test

in order to switch to the new user account, type in the su command as shown below :

su – username

Now in order to check that ‘sudo’ can be used with the new user account, invoke any command which require superuser privileges. For instance :

sudo whoami

Or simply try to list out all files under the root folder… sudo ls -l /root

You may be interested to read : How to become root user in Ubuntu

If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


amin nahdy

Amin Nahdy, an aspiring software engineer and a computer geek by nature as well as an avid Ubuntu and open source user. He is interested in information technology especially Linux based ecosystem as well as Windows and MacOS. He loves to share and disseminate knowledge to others in a transparent and responsible way.

Leave a Reply