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

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 bionic-security InRelease [88.7 kB]
Hit:2 bionic InRelease                                
Get:3 bionic-updates InRelease [88.7 kB]              
Hit:4 bionic InRelease                                
Get:5 bionic-backports InRelease [74.6 kB]            
Hit:6 stable InRelease                                    
Hit:7 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: Logo

You are commenting using your 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 Website.

Up ↑

%d bloggers like this: