In Linux, the administrator can create or add a user to the system to divide the task among other subordinate users. Administrators usually add regular users to the system to prevent them from accessing and messing up the base account. Adding multiple users on Ubuntu has many benefits, such as each user can customize the system according to their preferences and needs.
Administrators can create both regular and system users. A regular user only has administrator privileges or has access to the sudo command once you provide it. While, on the other hand, the system user is the one who has all administrator privileges and can modify critical system files and configurations.
Outline:
You can add user on Ubuntu 22.04 using:
The new user can be added on Ubuntu through the:
The adduser command creates a new user on the Linux system. It creates a home directory and configures the system for the new user side by side. Let’s check the instructions to add the user on Ubuntu 22.04.
Syntax:
Note: Remember to replace the [username] with the your desired username. For system users, add the “–system” flag.
Type the below command and execute it to add a user on Ubuntu 22.04:
You will be asked to:
Once the user is created, type the given command to verify whether the user was added successfully:
Specify the username with the “–system” flag to add the system user on Ubuntu:
Verify the user creation by executing the given command:
Note: By default, the command used to add a system user doesn’t allow you to set the password for a specific system user. You have to manually set the password for the system user by using the below-given command:
Note: If you created a system user, you may face an issue accessing the terminal from the system user account. If you encounter such an error, you can manually set it by first log in to the administrator account, and then running the following command to enable shell access for the system user:
Replace the username with your username:
The useradd command can also be used to create a new user on Ubuntu 22.04. However, by default, the useradd command does not create a home directory and does not configure the newly created user configurations.
Syntax
Let’s start by understanding the syntax:
Where options include:
Execute the useradd command with the username (without any options) to create a regular user:
Check whether the new user was created on Ubuntu by executing the id command followed by the username:
For a user on Ubuntu, you can set or change the password using the below command:
After the command execution, type the new password and retype to confirm:
To add a system user using the useradd command, execute the given command:
Note: You can also use the -r option instead of the –system flag to add a system user in Ubuntu:
Verify the username using:
The useradd command allows you to create and add a specific user to the group using a single command:
The -G denotes the group, and we have assigned the group to it by the name of linuxways, followed by the username to be created:
Verify the user creation and addition to the group by executing the id command followed by the username:
Note: When adding a system user, you can not set the password for the specific user. However, you can set the system user password manually by executing the given command:
The newusers command creates or updates the new users in bulk including regular and system users. The newusers command is mostly used in big IT companies where system administrators add a batch of users to the operating system. To add users in the batch using the newusers command, you have to create a text file first.
Syntax
Here is how to add the new user details in the text file:
Where,
Check the stepwise guide below to add multiple regular users on the Ubuntu system through the newusers command.
To create a batch of regular users, first, we need to create a text file to add the users to it using the nano text editor in the Terminal. For that, run the given command:
Let’s add six users including their details in the text file. A new line must separate each user detail:
linuxways2:pswd@123:1002:1002::/home/linuxways2:/bin/sh
linuxways3:pswd@123:1003:1002::/home/linuxways3:/bin/sh
linuxways4:pswd@123:1004:1004::/home/linuxways4:/bin/sh
linuxways5:pswd@123:1005:1005::/home/linuxways5:/bin/sh
linuxways6:pswd@123:1006:1006::/home/linuxways6:/bin/sh
Save the data and exit the file.
Provide that “.txt” file to the newusers command (as an argument), as shown below:
Check the user addition on Ubuntu by fetching the users from user ID 3 to 1000 by executing the below command:
Note: Adding multiple system users to the Ubuntu system is no different than adding the regular users except for adding the –system flag. The system user details are the same as the regular user except for adding a false value in the default shell environment and keeping the user ID range from 100-999.
Just like CLI, a user can also be added to Ubuntu 22.04 using GUI settings. The steps to add a user on Ubuntu 22.04 using GUI are below.
Hit the panel in the top-right corner and select Settings:
Navigate to the Users tab, and click on the Unlock button to configure users:
Enter the password to authenticate for user configuration:
Click on the Add User button to create a new user account:
Provide the user details such as account type, name, or password, and click the Add button to create the user account:
Note: To create the Administrator user, select the Administrator option.
Type the password and hit Authenticate to allow Ubuntu to add the user:
Open system Settings, navigate to the Users tab, and there you can see the newly added user on Ubuntu:
By default, every new user is created as the standard user in Ubuntu. To make it the administrator or sudo user, we need to execute a command manually.
Syntax
Remember: Replace the [Username] with your desired username.
Execute this code in the Terminal to add the user to the sudo group:
Execute the groups command along with the username to check the user addition in a sudo group:
The methods to remove a user on Ubuntu 22.04 are the same as for adding a user, such as using CLI and GUI.
Open Terminal and execute the below command to delete the user from Ubuntu:
Note: Replace johnny with the username you want to delete.
Verify the user deletion by executing this command:
Note: Replace the johnny username with the username you want to delete:
The output shows that the user no longer exists.
To remove a user from Ubuntu, open Settings, move to the Users tab, unlock the users, and click the Remove User button:
Select Delete Files to remove all files:
Enter the user password and click the Authenticate button to remove the user from Ubuntu:
Ubuntu lets you add users to the system, so you as a family can use a single machine individually with full privacy. Administrators can add a user on Ubuntu through Terminal and GUI. To add a user on Ubuntu using Terminal, users can use the useradd, newusers, and adduser commands. Moreover, to add a user using GUI, open Settings > Users, authenticate the system to configure users, hit the Add User button, add user details, and click the Add button.
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…
I don’t like my prompt, i want to change it. it has my username and…
Introduction: A Fragile Trust The Ruby ecosystem relies heavily on RubyGems.org as the central platform…