Add and Delete User in Ubuntu, Debian & LinuxMint

You may need to create separate account for every user want to connect this system. For adding new users in system there are two commands available in your system, useradd and adduser. adduser command is the enhanced version of useradd command. adduser command uses useradd command in backend. This tutorial 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 ‘guest’ on your system
$ sudo adduser guest

Adding user `guest' ...
Adding new group `guest' (1003) ...
Adding new user `guest' (1003) with group `guest' ...
Creating home directory `/home/guest' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: **************
Retype new UNIX password: ************** 
passwd: password updated successfully
Changing the user information for guest

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 at any other location using following command.
$sudo adduser guest --home=/var/home/guest
You can also specify any other shell for user in place of default, use –shell switch followed by shell name as below.
$ sudo adduser guest --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.
$ sudo adduser guest --no-create-home

2. Delete User from System

Now its good to lock or delete any user from system which is no longer required. Use the following command to delete any user from system.
$ sudo deluser guest
The above command will not delete users home directory. If you also want to delete users home directory add –remove-home parameter with command, For example below command will delete user guest and their home directory permanently.
$ sudo deluser guest --remove-home
You may also take backup of users home directory before deleting it using following command.
$ sudo deluser guest --remove-home --backup  --backup-to /var/archives/

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment