How To Create A Root Account Ubuntu 16.04

Step 1: Create a user

1.1 Run commands in root

sudo su
stek@srv10:~$ sudo su
[sudo] password for stek:
root@srv10:/home/stek#

1.2 Add user

sudo adduser 'user-name'
root@srv10:~# adduser temp1
Adding user `temp1' ...
Adding new group `temp1' (1003) ...
Adding new user `temp1' (1003) with group `temp1' ...
Creating home directory `/home/temp1' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for temp1
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] Y
root@srv10:~#

1.3 Add user to sudo group

sudo usermod -G sudo 'user-name'
root@srv10:~# sudo usermod -G sudo temp1
root@srv10:~#

Step 2: Grant Root Privileges to the User

2.1 Edit /etc/sudoers

sudo visudo

Find the following lines:

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

Add this line under “# User privilege specification”

'user-name'             ALL=(ALL) ALL
# User privilege specification
root    ALL=(ALL:ALL) ALL
temp1   ALL=(ALL) ALL

Exit & Save

2.2 Reboot the server and log in with the new user

sudo reboot    

Step 3: Delete a user and home folder

3.1 Delete user and home folder

sudo deluser 'user-name' --remove-home
sudo deluser stek --remove-home
temp1@srv10:~$ sudo deluser stek --remove-home
[sudo] password for temp1:
Looking for files to backup/remove ...
Removing files ...
Removing user `stek' ...
Warning: group `stek' has no more members.
Done.
temp1@srv10:~$


Donate