In This tutorial we will help you to add and delete user in Ubuntu, Debian and LinuxMint operating systems.
1. Add New User
For this tutorial we are using adduser command for examples. Following command will create new user named ‘seemab’ on your system.
adduser seemab Adding user `seemab' ... Adding new group `seemab' (1006) ... Adding new user `seemab' (1005) with group `seemab' ... Creating home directory `/home/seemab' ... Copying files from `/etc/skel' ... Enter new UNIX password: ************** Retype new UNIX password: ************** passwd: password updated successfully Changing the user information for seemab 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
By default above command will create users home directory as /home/. But you can specify home directory as per your choice at any other location using following command.
adduser seemab --home=/var/home/Seemab
We can also specify any other shell for user in place of default.
adduser seemab --shell=/bin/bash
If you don’t want to create users home directory. You can use –no-create-home switch with adduser command as below:
adduser seemab --no-create-home
2. Delete User from System
Now you can easily delete any user from system which is no longer required. Use the following command to delete any user from system.
The above command will not remove users home directory. If you want to delete users home directory too add –remove-home parameter with your command, For example:
deluser seemab --remove-home
You can also take backup of users home directory before removing it using below command:
deluser seemab --remove-home --backup --backup-to /var/backup/