This article will explain to you how to create a new user on Ubuntu OS through the UI and the Command line. Also, we will explain how to assign sudo privileges to the user and how to delete it in case you want to. We have run the commands and procedure explained in this article on a Ubuntu 20.04 LTS system.
Note: In order to add or delete a user account, you must have administrator privileges.
Creating the User Account using UI
To create the new user account via UI, follow these steps:
- Open the Settings utility using the right-click menu from desktop.
- Then navigate to the Users tab from the left panel. On the right panel, you will see all the fields disabled by default. To make any changes, you will need to unlock the settings. In the top right corner, hit the Unlock button. The following Authentication dialog box will show up. Type the password and click the Authenticate button. By doing so, all fields will be enabled.
- Next, click the Add User button.
- The following dialog box will open asking you to enter the required information for the new user to be created. You can choose to create a Standard or an Administrator account by selecting the tab in front of Account Type. Administrator account has more privileges than the standard user account and they can install, remove and update software, add and remove users and make configurations.Type the user name and set a password for it or let the user set it when they next log in. Then click the Add button.
Now the user account has been created and you will see it listed in the Users window.
Deleting the User Account using UI
If you want to delete the user account using the UI, follow the below simple steps:
- Open the Settings utility using the right-click menu from desktop.
- Then navigate to User tab. On the right panel, you will see all the fields disabled by default. To make any changes, you will need to unlock the settings. In the top right corner, hit the Unlock button.
- In the following authentication dialog, type password and click the Authenticate button.
- Select the account you want to remove and hit the Remove User button. Next, it will ask if you want to keep or remove the Home directory of user. You may choose to remove or keep the files through the corresponding buttons.
After that, the user account will be removed from your system.
Creating a User Account using the Command Line
To create a new user account using the Command line, follow the below steps:
- Hit Ctrl+Alt+T to launch the command line Terminal application in Ubuntu.
- Now in order to create a new user account, use adduser command as follows:
Replace
As an example, we are creating the user account with the name “guest”, so the command would be:
$ sudo adduser guestEnter the sudo password. Then type and re-type the password for the new user account. You can provide other information or press Enter to accept the default.
Once done, you will be asked to confirm the information by providing with Y/n option. Hit y to confirm, after that the user account will be created in your system.
- Once added, you can verify the newly added user account with the following command:
- If you want to grant sudo privileges to the user, you can do so with the following command:
In our example, it would be:
$ sudo usermod -aG guest
It will add the user to the sudo group and will assign administrative rights.
Deleting the User Account using the Command Line
In order to delete the user account using the command line, use the following syntax:
$ sudo deluser
That is all there is to it! I hope this will be helpful if you ever need to create a new user account in Ubuntu 20.04 LTS system.