Home // How to Add and Remove Users on Ubuntu 16.04 to 22.04

How to Add and Remove Users on Ubuntu 16.04 to 22.04

0 3 mins read
| Published on: June 12, 2022 | Last updated on: July 31, 2023

Adding and deleting ubuntu user accounts is one of the first steps when configuring a new Ubuntu system. Each user may have unique permission levels and settings for command-line and graphical user interface apps.

This article describes how to create and delete Ubuntu user accounts.

Before You Begin

Make sure you’ve installed Ubuntu correctly, follow this guide if you need to do it still!

Only root or users with sudo permissions may create or delete users..

There are two methods to create new users:

  1. Using the terminal.
  2. Using the GUI.

Adding a User from the Command Line

You may create a new user account in Ubuntu using one of two command-line tools called useradd or adduser. Both of these tools are available to you.

useradd is a fundamental tool.

adduser is a Perl script that was designed to serve as a user-friendly and interactive interface for the useradd command.

Invoking the adduser command followed by the username is all that is required to create a new user in a flash and with no effort. For instance, if you wanted to establish a new ubuntu user account and give it the name 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' ...

There will be a number of questions directed at you. Please enter the new user password and confirm it. It is not required that you provide a response to any of the other questions.

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] 

You will be asked to verify the accuracy of the information that you supplied before the process is complete.

The command will establish a home directory for the new ubuntu user and then transfer files from the /etc/skel directory into it. The user has the ability to create, modify, and remove files and folders while working inside their home directory.

You need to add the new user to the sudo group in order for the user to have the ability to carry out administrative responsibilities:

sudo usermod -aG sudo username

Add a User Via the Graphical User Interface (GUI)

You may create a new user account using the GUI if you are uncomfortable working with the command line. To do this, please proceed as outlined below:

  1. Launch the window that controls the settings, then go to the “Users” tab.
  2. To unlock your account, click the option labelled “Unlock,” and then enter your user password when required to do so.
  3. When you have successfully entered the correct password, the “Unlock” button will transform into a green “Add User” button.
  4. When you choose the “Add User” option from the drop-down menu, the Add user dialogue box will display.
  5. Enter details about the new user after selecting whether they should be a normal user or an administrative user. After you have finished, click the “Add” button.

Deletion of a User from the Command Line

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

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

sudo deluser username

The command above will not remove the user files.

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

sudo deluser --remove-home username

Removing a User through the GUI

  1. Open the settings window and click on the “Users” tab.
  2. Click on 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 bottom right corner.
  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 removes the user.

Conclusion

IF YOU ARE HAVING PROBLEMS WITH THIS GUIDE, EMAIL US AT:

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

Copyright @2022-2024 All Right Reserved – PCPlanet

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. You understand and give your consent that your IP address and browser information might be processed by the security plugins installed on this site. By clicking “Accept”, you consent to the use of ALL the cookies.
.
Accept Read More

Privacy & Cookies Policy