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:
- Using the terminal.
- 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:
- Launch the window that controls the settings, then go to the “Users” tab.
- To unlock your account, click the option labelled “Unlock,” and then enter your user password when required to do so.
- When you have successfully entered the correct password, the “Unlock” button will transform into a green “Add User” button.
- When you choose the “Add User” option from the drop-down menu, the Add user dialogue box will display.
- 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
sudo deluser --remove-home username
Removing a User through the GUI
- Open the settings window and click on the “Users” tab.
- Click on the “Unlock” button, and enter your user password when prompted.
- Click on the username you want to delete, and you will see a red “Remove User..” button in the bottom right corner.
- 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.