How to Add and Delete Users on Ubuntu 18.04

Updated on

4 min read

Add and Delete Users on Ubuntu

Ubuntu, like any other Linux distribution, is a multi-user operating system. Each user can have different permission levels and specific settings for various command-line and GUI applications.

Knowing how to add and remove users is one of the basic skills a Linux user should know.

In this tutorial, we will show you how to add and remove users on Ubuntu 18.04.

Prerequisites

To be able to create and remove users, you need to be logged in as root or user with sudo privileges .

How To Add User in Ubuntu

One can create a new user account in Ubuntu in two ways:

  1. From the command line.
  2. Through the GUI.

Add a New User from the Command Line

In Ubuntu, there are two command-line tools that you can use to create a new user account: useradd and adduser.

useradd is a low-level utility for adding users, while the adduser a friendly interactive frontend to useradd written in Perl.

To create a new user account named username using the adduser command you would run:

sudo adduser username
Adding user `username' ...
Adding new group `username' (1001) ...
Adding new user `username' (1001) with group `username' ...
Creating home directory `/home/username' ...
Copying files from `/etc/skel' ...

You will be asked a series of questions. The password is required, and all other fields are optional.

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for username
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] 

Finally, confirm that the information is correct by entering Y.

The command will create the new user’s home directory, and copy files from /etc/skel directory to the user’s home directory. Within the home directory, the user can write, edit, and delete files and directories.

By default on Ubuntu, members of the group sudo are granted with sudo access.

If you want the newly created user to have administrative rights, add the user to the sudo group :

sudo usermod -aG sudo username

Add a New User through the GUI

If the command-line is not your thing, you can add a new user account through the GUI.

  1. In the Activities screen, search for “users” and click on “Add or remove users and change your password”.

  2. In the new window, click on the “Unlock” button, and enter your user password when prompted.

    Ubuntu Users Window

    Once you enter the password, the “Unlock” button will change to a green “Add User” button.

  3. Click on the “Add User” button, and the Add user dialog will appear:

    Ubuntu Add User
  4. Select whether the new user should be a standard or administrator user and enter information. Once done, click on the “Add” button.

How To Delete a User

If the user account is no longer needed, you can delete it either from the command line or via GUI.

Delete a User from the Command Line

There are two command-line tools that you can use to delete a user account: userdel and deluser. On Ubuntu, you should use the deluser command as it is more friendly than the low-level userdel.

To delete the user, without removing the user files, run:

sudo deluser username

If you want to delete the user and its home directory and mail spool, use the --remove-home flag:

sudo deluser --remove-home username

Delete a User through the GUI

  1. In the Activities screen, search for “users” and click on “Add or remove users and change your password”.

  2. In the new window, click on the “Unlock” button and enter your user password when prompted. Once you enter the password, the “Unlock” button will change to a green “Add User” button.

  3. Click on the username you want to delete, and you will see a red “Remove User..” button on the bottom right corner.

    Ubuntu Remove User
  4. Click the “Remove User..” button, and you will be prompted whether to keep or delete the user home directory. Clicking on one of those buttons will remove the user.

Conclusion

In this tutorial, you learned how to add and remove users in Ubuntu. The same commands apply for any Ubuntu-based distribution, including Debian, Kubuntu, and Linux Mint.

Feel free to leave a comment if you have any questions.