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 sudoers file. You will then be able to execute commands which require administrator privileges without logging in as a root user.

Simple steps to create a new sudo user

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

ssh root@server_ip_address

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

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.

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

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

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu
Show Buttons
Hide Buttons