How To Add a User and Grant Root Privileges on Ubuntu

Step 1: Add the Username

austin@wazuh:~$ sudo adduser ansible
Adding user `ansible' ...
Adding new group `ansible' (1002) ...
Adding new user `ansible' (1002) with group `ansible' ...
Creating home directory `/home/ansible' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
No password supplied
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for ansible
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] 

Step 2: Grant Root Privileges to the User

austin@wazuh:~$ sudo visudo
austin@wazuh:~$ su - ansible
Password: 

Place user under root

# User privilege specification
root    ALL=(ALL:ALL) ALL
ansible ALL=(ALL:ALL) ALL
ansible@wazuh:~$ sudo apt-get update
[sudo] password for ansible: 
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease                                
Get:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]              
Hit:4 https://deb.nodesource.com/node_8.x bionic InRelease                                
Get:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]            
Hit:6 http://linux.teamviewer.com/deb stable InRelease                                    
Hit:7 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease                 
Fetched 252 kB in 1s (249 kB/s)                    
Reading package lists... Done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

A WordPress.com Website.

Up ↑

%d bloggers like this: