How to Add New User in Ubuntu and Grant it Sudo Privileges

Adding New User

Add new user with the following command

sudo adduser newuser

after that ubuntu will ask you for your new user’s password and other information

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for newuser
Enter the new value, or press ENTER for the default
	Full Name []: Example of Newuser
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:
Is the information correct? [Y/n] y

Granting Sudo Privileges

if you want your new user’s have ability to run command with root privileges, like sudo apt-get update, sudo apt install etc, you will need to register your new user to sudoers. to give that root privileges simply run the following command :

sudo usermod -aG sudo newuser

Test User’s Privileges

first you need to login as your new user with

su - newuser

then input your newuser password. After you logged in, try sudo command like

sudo apt-get update

if the current user have a sudo privileges, then the command should run smoothly, while if not, it will tell you something like

username is not in the sudoers file. this incident will be reported.

 

Leave a comment