How to Add and Delete Users on Ubuntu 18.04

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

Understanding how to add and remove users is one of the necessary skills a Linux user should know, as it is the primary task.

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

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

How To Add User in Ubuntu

You can create a new user account in Ubuntu in two ways, which are as follows:

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

Add a New User from the Command Line

Two command-line tools can create a new user account that is useradd and adduser tool in Ubuntu.

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

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

$ sudo adduser username
Output:

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.

Output:

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, if you want to confirm that the information is correct then enter Y.

The command will create the new user’s home directory, copy files from the/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 you are not satisfied with the command line, you can add a new user account through the GUI also. To do so, you will need to follow the steps given below:

  1. The first step is to search for “users” in the activation screen and then click on “Add or remove users and remember to change your password.”
  2. Then you will need to click on the “Unlock” button and open your user password when mentioned.
  3. After you enter the password, the “Unlock” button will convert to a green “Add User” button.
  4. Then you will need to click on the “Add User” button, and then Add user dialog will arrive:
  5. Then you will need to select whether the new user should be a standard or administrator user and insert information. Once done, then you will need to click on the “Add” button.

How To Delete a User

If the user account is no longer in use, then you can delete it each from the command line or GUI, whichever is preferred.

Delete a User from the Command Line

Two command-line tools can create a new user account that is userdel and deluser tool in Ubuntu. Where useradd is used as a low-level utility for adding users, while the adduser a friendly interactive frontend to useradd written in Perl language and it is more preferred to use.

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

$ sudo deluser username

The following command is used 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. The first step is to search for “users” in the activation screen and then click on “Add or remove users and remember to change your password.”
  2. Then click on the “Unlock” button, and insert your user password when mentioned.
  3. Then click on the username you want to delete, and you will observe a red “Remove User..” button on the base right corner, which indicated that the user could be removed.
  4. Then click the “Remove User..” button, and you will be mentioned whether to keep or delete the user home directory. By clicking on one of those buttons removes the user that you are willing to do.

Conclusion

In this article, you have learned how to add and remove users in Ubuntu. If you have any queries related to this topic, you can leave comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *