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