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,

Related :   How to block unwanted websites using your router in a home wifi network ?

$ 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 


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded