Create and delete a user in Ubuntu

It is always better to have a user through whom we could do routine tasks. For instance, we don’t require root account privileges to edit a document or spreadsheet. Although by default, Ubuntu desktop users can’t login as root. And, the user which we created during Ubuntu installation process can execute administrative tasks through privilege escalation i.e. sudo. We have already discussed how to add a user to sudoers in Ubuntu. This article solely focus on how to create and delete a user in Ubuntu distribution.

We would use adduser and userdel command-line utilities to get the desired outcome.

Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.

Create a new user in Ubuntu distribution

We can create a new user in Ubuntu through adduser command-line utility. For instance, if we want to create a new normal user – testuser

So, issue the following in terminal –

sudo adduser testuser

It will return with the following and prompt us for the password –

Adding user `testuser' ...
Adding new group `testuser' (1001) ...
Adding new user `testuser' (1001) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
New password:

At this stage, enter a password of our choice and press Enter. Next, it will ask us to Retype the password.

Retype new password: 
passwd: password updated successfully
Changing the user information for testuser

Thereafter, it will ask us for provide few general entries like Full Name, Contact numbers etc.

Enter the new value, or press ENTER for the default
Full Name []: 
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []:

Lastly, we will get a prompt to confirm whether all entered details are correct. Press Y if correct else N.

Is the information correct? [Y/n]

adduser command-line utility also creates a group testuser, home directory, copies files from /etc/skel directory to our home directory among others. It basically acts as a front-end for useradd & passwd command-line utility. Although, similar results could be achieved using useradd and passwd command-line utility. But, we would have to manually provide the details in that case. With adduser we have streamlined the entire process of user creation.

If in case, we would want the users’ home directory or default shell to be different from what adduser specifies. Then, we can provide the relevant details as mentioned below –

sudo adduser testuser --home /path/to/home/ --shell <default_shell>

Delete a user in Ubuntu distribution

A user can be deleted using userdel command-line utility. Therefore, issue the following in terminal –

userdel -r testuser


-r option –> remove user’s home directory & mail spool

If, for some reason, we would want to keep user’s home directory & mail spool then –

userdel testuser

In conclusion, we have discussed how to create and delete a user in Ubuntu distribution through adduser and userdel command-line utilities.

Similar Posts