Category Archives: Ubuntu

How to Add and Remove Users on Ubuntu 20.04

When provisioning a new Ubuntu system, the main task to be done is adding and removing users. Each user can have various permission levels and specific settings for different command-line and GUI applications.

So in this article, we have explained how to add and remove user accounts on Ubuntu 20.04

Before we start

Let us see some points.

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

The following two ways are used to create new users:

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

Adding a User from the Command Line

In Ubuntu, there are a couple of command-line tools that you can do to create a new user account that is useradd and adduser.

useradd is a low-level utility. adduser is a script written in Perl that works as a friendly interactive frontend for useradd.

It is swift and easy to add a new user. Entreat the adduser command accompanied by the username. For example, to produce a new user account named username, you would work on the subsequent command

$ 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 examined a series of problems. Enter and validate the new user password. Answering all other questions is voluntary.

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]

In the end, you will be required to confirm that the information you typed is accurate or not

The command will generate the new user’s home directory and copy files from /etc/skel to it. Inside the home directory, the user can write, edit, and delete files and directories which they want.

If you need the new user to be capable of performing administrative tasks, you require to add the user to the sudo group :

$ sudo usermod -aG sudo username

Adding a 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 open the settings window and click on the “Users” tab.
  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.

Removing a User from the Command Line

The following two commands are used in Ubuntu to delete a user account: userdel and its interactive frontend deluser.

To delete the user, request the deluser command and pass the username as the argument:

$ sudo deluser username

The above command will not remove the user files.

If you need to delete the user and its home directory and mail spool, use the –remove-home flag command for a better result.

 Removing a User through the GUI

  1. The first step is to open the settings window and click on the “Users” tab.
  2. Then click on the “Unlock” button, and insert your user password when mentioned.
  3. Then click on the username which 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 determined how to add and remove users in Ubuntu 20.04. Understanding how to add and remove users is one of the essential skills a Linux user should know.

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.