How To Create Root Account Ubuntu 18.04 Bionic Beaver

Step 1: Create a user

1.1 Run commands in root

sudo su
stek@srv6:~$ sudo su
[sudo] password for stek:

1.2 Add user

sudo adduser 'user-name'
root@srv6:/# sudo adduser steken
Adding user `steken' ...
Adding new group `steken' (1001) ...
Adding new user `steken' (1001) with group `steken' ...
Creating home directory `/home/steken' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Enter the user’s password twice

Press enter to fill the fields with default information

Changing the user information for steken
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

Enter Y then hit enter to continue

1.3 Add new user to sudo group

sudo usermod -G sudo 'user-name'
root@srv6:/# sudo usermod -G sudo steken

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
# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
steken  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
steken@srv6:~$ sudo deluser stek --remove-home
[sudo] password for steken:
Looking for files to backup/remove ...
Removing files ...
Removing user `stek' ...
Warning: group `stek' has no more members.