Home » Linux Host, Ubuntu, SysAdmin » System Administration, Security » How to Add new user and Delete existing user on Ubuntu ?

How to Add new user and Delete existing user on Ubuntu ?

In this post we demonstrate, how you can create a new user in Ubuntu, give the sudo / admin permissions to this user and also delete any existing user.

Adding a new user in Ubuntu

root@ubuntu:/# adduser "MYNEWUSER"
Adding user `"MYNEWUSER"' ...
Adding new group `"MYNEWUSER"' (1001) ...
Adding new user `"MYNEWUSER"' (1001) with group `"MYNEWUSER"' ...
Creating home directory `/home/"MYNEWUSER"' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for "MYNEWUSER"
Enter the new value, or press ENTER for the default
Full Name []: MY Username
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

Now, if we check the home directory of the newly created user, we will see it only created “examples.desktop” and nothing else like Desktop, Downloads etc.

$ ls /home/MYNEWUSER/
examples.desktop

Note: if we want to have those all directories, we have to logout currrent user from GUI i.e. from Top Right -> Settings Wheel -> Select Newly created user Or click “Logout” and then login to new user from GUI, and we will see the directores like below created now,

$ ls /home/MYNEWUSER/
dead.letter Desktop Documents Downloads examples.desktop Music Pictures Public Templates Videos

 root@ubuntu:/# su "MYNEWUSER"

We have added a new user “MYNEWUSER” , but this user will not have a sudo permission which we can check it as,

"MYNEWUSER"@ubuntu:/$ sudo ls
sudo: unable to resolve host ubuntu
[sudo] password for "MYNEWUSER":
"MYNEWUSER" is not in the sudoers file.  This incident will be reported.

Allow “sudo” permission to new user

Now to add this user in the sudoer’s list, please check the post at https://lynxbee.com/fix-lost-sudo-user-in-linux/

This can also be done as,

$ sudo su 
root@ubuntu:/# adduser MYNEWUSER sudo 
sudo: unable to resolve host ubuntu
Adding user `MYNEWUSER' to group `sudo' ...
Adding user MYNEWUSER to group sudo
Done. 

Delete existing user in Ubuntu

To delete the user and its home directory, use below command,

 $ sudo deluser --remove-home MYNEWUSER 


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment