List of content you will read in this article:
Why should you learn about adding or removing users on Ubuntu?
In a Linux system, different groups are created for various developers or users with distinct privileges.
Therefore, each user must have their account and password and have access to special files and directories according to their specific privileges.
As a security measure, it is recommended to assign limited permissions to user accounts as much as possible and always be careful to remove inactive accounts.
Types of the different user account on Ubuntu Linux
There are three main types of accounts in this system:
1. The root user account
The root is the main user account in this operating system, which is spontaneously created during installation.
This has the highest privilege, allowing the user to do any administrative job such as installing/uninstalling software or packages, altering the configuration, etc.
The root user can also access any services through the system. This type of account is created for administrative purposes, as mentioned earlier.
Therefore, regular users should not use it for ordinary tasks and activities. The root account can not be deleted but can be disabled if required.
2. The regular user account
Throughout the installation process, one regular user account is created automatically. It is designed for ordinary users with moderate privilege.
When you install OS successfully, you can create as many regular accounts as you need and set limited access to authorized files and services for any users. You can remove or disable these types of user accounts as per requirement.
3. The service user account
This account is created for running specific processes and executing functions which are not used for routine jobs.
Adding a user on Ubuntu
There are two main ways to add a user to this popular Linux-based operating system:
- Using the command line
- Using the GUI (graphical user interface)
How to add a user on Ubuntu using the command line?
Using the Ubuntu Linux terminal command line is one of the common ways to add a user to your system. Hence, it is necessary to follow these steps:
- Press Ctrl + SHIFT +T or use the application manager to launch your terminal.
- If you are logged in as a root account, you can create a new user by running the “adduser newuser” command.
- If you are logged in as a regular or service account user, you can add a new user by running “sudo adduser newuser” command.
In both cases, you will be asked to answer a series of questions such as:
- Set and confirm a password for the new user.
- Enter any additional information about the new user; this is optional, and you can press ENTER if you do not want to enter any additional information.
- Finally, you will be asked to confirm the accuracy of the information provided. Press Y to continue.
- Your new user is now ready to log in to the system using the password you entered.
- You can also add an existing user to the desired group by running “adduser” command.
How to set a new user password on Ubuntu using the command line?
You can change the password using the “passwd” command any time you want:
# passwd john
Changing password for user john.
Retype new password:
all authentication tokens updated successfully.
How to add groups on Ubuntu through the command line?
All users on an Ubuntu system are members of one or more groups. By default, new users are added to a private group with their own user name (In the above example, a user named John is a private group member with the same name).
As an administrator, creating different groups and adding or removing users to an appropriate one according to their tasks is the most important part of your job.
For example, you should add all salespeople to a single group, while accounting staff may belong to the accounts group, and so on. You can add new groups to the system using the “addgroup” command:
# addgroup accounts
How to remove a user on Ubuntu using the command line?
- You can type “deluser” in the command line to remove an existing user while keeping the entire files and data on the system intact:
# deluser john
- The user's home directory and mail spool can also be deleted as a part of the removal process:
# deluser --remove-home john
How to remove an existing group on Ubuntu using the command line?
- To remove an existing group, you can easily type “delgroup” in the command line:
# delgroup accounts
You can never delete a primary group while the users have active accounts.
If you want to remove such a group, first, you should delete the existing user account or create a new primary group and assign it to the mentioned user by “usermode” command.
Then, you can add a user to a new primary group by “usermod –g” command:
# usermod -g sales john
# delgroup accounts
How to find the user’s group on Ubuntu?
- To find the groups a user belongs to, you can run the “group” command:
$ groups john
john : accounts support
How to add a user account on the Ubuntu desktop?
To add a user to your Ubuntu desktop (Gnome), you can follow these steps:
- Press the super key on your keyboard.
- Click on Show Applications in the bottom left corner of your screen.
- Type “setting” into the search bar.
- Click on the setting icon when it appears.
- Click on the “users” button on the setting menu.
- Click on the “unlock” button in the top right corner of your screen.
- Enter your password.
- Click on the “authenticate” button to unlock the user setting.
- Click on the “Add User” button at the top of the setting window.
- Choose the account type (Standard/Administrator).
- Enter the user’s full name.
- Enter the user’s account name.
- Choose whether you want to “allow the user to set a password when they next login” or “set a password now”.
- If you choose “set a password now,” you should enter the new password into the Password and Confirm boxes.
The Bottom Line
In this article, you learned about adding/removing a user on Ubuntu in different ways. By following these methods, you can easily manage your system. What is your opinion? Which method is more confident for you? Please share your experiences and ideas with us.
People also read: