Hamsa K
Editor
3 min read | 4 years ago

How to Create Sudo User in Ubuntu 18 04

Create sudo user in ubuntu 18.04

In linux root user is having all rights and permissions to do all tasks.Due to some security reasons it is recommended to use the sudo command to gain root privileges when a system user really needs to. On Ubuntu systems, root account is disabled by default and the default account is an administrative account which uses sudo to obtain root privileges.

Step 1: First we will login into the root user

If we have root access then use below command

ssh root@server_ip_address

if you have default user account as test then 

test@lampblogs:~$ sudo su -
[sudo] password for test:
root@lampblogs:~# 

Step 2: create new user account

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

 Step 3: Add user to sudo group

root@lampblogs:~# usermod -aG sudo bobby

Step 4: Test sudo Access

Now switch to  new user like below

root@lampblogs:~# su - bobby
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
bobby@lampblogs:~$

use sudo command ro run whoami command 

bobby@lampblogs:~$ sudo whoami
[sudo] password for bobby:
root

First time you use sudo it will be prompted to enter the user password.Now you can run any administrative tasks. 

sample output:

bobby@lampblogs:~$ sudo mkdir -p /srv/www/test
bobby@lampblogs:~$ cd /srv/www/test/
bobby@lampblogs:/srv/www/test$

 Thats'it.Now we have successfully created sudo user in ubuntu system.

 

 



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy