How to add and remove users on Ubuntu 20.04

s2 0

One of the first tasks in deploying a new Ubuntu system is adding and removing users. Each user can have different authorization levels and specific settings for different command line and GUI applications.

This article explains how to add and remove user accounts on Ubuntu 18.04.

before you start

Only root or users with sudo privileges can create and remove users.

New users can be created in two ways:

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

Add a user from the command line

There are two command line tools in Ubuntu that you can use to create a new user account: useradd and adduser.

useradd

is a low-level utility. adduser is a script written in Perl that serves as a user-friendly interactive front end for useradd.

Adding a new user is quick and easy, just give them a call adduser Command followed by the username. For example, to create a new user account named. to create username 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. Enter the new user password and confirm it. Answering all other questions is 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] 

At the end, you will be asked to confirm that the information you entered is correct.

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

If you want the new user to be able to perform administrative tasks, you need to add the user to the sudo group:

sudo usermod -aG sudo username

Adding a user through the GUI

If you are not familiar with the command line, you can add a new user account using the GUI. To do this, follow the steps below:

  1. Open the Settings window and click the User tab.

  2. Click the Unlock button and enter your user password when prompted.

    As soon as you have entered the password, the “Unlock” button changes to a green “Add user” button.

  3. Click the “Add User” button and the Add User dialog is displayed:

  4. Choose whether you want the new user to be a standard or administrator user and fill in information. When you’re done, click the Add button.

Remove a user from the command line

In Ubuntu, you can use two commands to delete a user account: userdel and its interactive front end deluser.

To delete the user, call the deluser Command and pass the username as an argument:

sudo deluser username

The above command does not remove the user files.

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

sudo deluser --remove-home username

Remove a user from the GUI

  1. Open the Settings window and click the User tab.

  2. Click the Unlock button and enter your user password when prompted.

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

  4. Click the “Remove User ..” button and you will be asked whether you want to keep the user’s home directory or delete it. Clicking one of these buttons removes the user.

diploma

We showed you how to add and remove users in Ubuntu 20.04. Knowing how to add and remove users is one of the basic skills a Linux user should know.

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