How to Add new user and Delete existing user on 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.

Now to add this user in the sudoer’s list, please check the post at http://www.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. 

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

 $ sudo deluser --remove-home MYNEWUSER 
Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded
Tags: ,

Leave a Reply