How to Add and Delete Users on Ubuntu 18.04 & 20.04 2024

How to Add and Delete Users on Ubuntu

Looking to manage user permissions and settings on your Ubuntu system? Look no further than this step-by-step tutorial on adding and removing users on Ubuntu 20.04 and Ubuntu 18.04! As a multi-user operating system, Ubuntu offers granular control over individual user accounts, with unique permissions and preferences for both command-line and GUI applications.

Learn the basics of user management on Linux, and ensure your Ubuntu system is secure and efficient for all users.

Prerequisites

In order to manage user accounts, it is necessary to have root access or be a user with sudo privileges.

There are two methods of creating new users:

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

Adding a User from the Command Line

You can utilize two command-line tools, namely useradd and adduser, to generate a fresh user account in Ubuntu.

useradd is a utility that operates at a low level, while adduser is a Perl script designed to serve as a user-friendly interactive interface for useradd.

To create a new user account, you can use the adduser command followed by the desired username. For instance, if you want to add a user with the username “username“, simply run the adduser command. This process is quick and straightforward:

ShellScript
sudo adduser username

Output:

Adding user username' ...
Adding new groupusername’ (1001) …
Adding new user username' (1001) with groupusername’ …
Creating home directory /home/username' ...
Copying files from/etc/skel’ …

A set of questions will be presented to you, and you will be required to input and verify the new user password. Answering the remaining questions is not mandatory.

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]

To ensure the accuracy of the information, please enter ‘Y‘ to confirm.

After executing the command, a home directory will be generated for the new user, and files from the /etc/skel directory will be duplicated into the user’s home directory. The user will be able to create, modify, and remove files and directories within their home directory.

To grant the new user the ability to execute administrative tasks, it is necessary to add the user to the sudo group:

ShellScript
sudo usermod -aG sudo username

Adding a User through the GUI

In case you feel uneasy using the command line, an alternative method for creating a new user account involves utilizing the graphical user interface. To proceed with this approach, refer to the step-by-step instructions outlined below:

  • To access the Users tab, you need to open the settings window and click on it.
  • Once prompted, input your user password and click the Unlock button.
ubuntu users window ubuntu 18.04
Ubuntu 18.04
ubuntu users window ubuntu 20.04
Ubuntu 20.04

After inputting the password, the “Unlock” button will be replaced with a green “Add User” button.

  • Upon clicking the “Add User” button, the Add User dialog box will be displayed:
add user on ubuntu 18.04
Ubuntu 18.04
add user on ubuntu 20.04
Ubuntu 20.04
  • You have the option to choose between a standard or administrator user for the new user, and provide the necessary information. Afterward, simply click on the “Add” button to complete the process.

Removing a User from the Command Line

There are two ways to delete a user account in Ubuntu: using the command “userdel” or its interactive front-end “deluser“.

You can remove a user by using the deluser command and specifying the username as the parameter.

ShellScript
sudo deluser username

Executing the aforementioned command will leave the user files intact and not delete them.

To remove a user along with their home directory and mail spool, simply add the “--remove-home” flag:

ShellScript
sudo deluser --remove-home username

Removing a User through the GUI

  • To access the “Users” tab, you need to open the settings window first.
  • To unlock, simply click on the designated “Unlock” button and provide your user password as prompted.
  • If you want to delete a username, simply click on it, and a red button labeled “Remove User…” will appear in the bottom right corner.
remove user on ubuntu 18.04
Ubuntu 18.04
remove user on ubuntu 20.04
Ubuntu 20.04
  • After clicking the “Remove User…” button, a prompt will appear asking whether to retain or delete the user’s home directory. Selecting either option will result in the removal of the user.

Conclusion

In this tutorial, we have demonstrated the process of adding and deleting users in both Ubuntu 18.04 and 20.04. These fundamental skills are essential for any Linux user to possess. If you have any queries, please feel free to drop a comment below.

Alex

Alex

Hey there! My name is Alex and I'm a professional content writer. I'm also lucky enough to be part of an amazing trio team! I absolutely love what I do and I'm passionate about creating content that engages, informs, and entertains. Whether it's writing blog posts, website copy, or social media content, I always strive to deliver high-quality work that exceeds expectations.

We will be happy to hear your thoughts

Leave a reply

TrioGuide
Logo