Thursday, November 13, 2014

How to create new users in Ubuntu/ Debian and delete them

Creating new users is the probably the most basic task in a linux system. Though there are lot of forum posts which help you in this, I am going to post once again for someone who might benefit from it.

For this posting, we shall call this new user as 'tedy'. So be sure to substitute this user with your username.

To create a new user:

sudo useradd -m tedy


adding -m flag will create a home directory for 'tedy'  as well.

When the user is created there is no password for him/her

So, issue the following command to create a password for the new user 'tedy'

sudo passwd tedy


Now if you want 'tedy' to be an administrator or superuser or root you have to add him to the group "sudo", for this:

sudo adduser tedy sudo


Now we have to specify which shell tedy should use, we specify that in case your distro cannot map it directly

sudo chsh -s /bin/bash tedy


That's it you have created a brand new user account with superuser powers

The simplest way of removing our new user 'tedy' involves two commands

sudo userdel tedy


then remove his home totally

sudo rm -r /home/tedy


You might need to delete or add new users to test a new gui settings of a beta distribution which gets updated daily.


The default user created in Ubuntu will be a part of several groups such as adm, cdrom, lpadmin etc so we need to add our new user tedy to those groups in case he has to act as the same user created by Ubuntu by default during install.




sudo usermod -a -G adm,cdrom,lpadmin,sudo,sambashare,dip,plugdev tedy