Managing users may not sound like the most daunting task, but it is still an essential part of the work of a busy system administrator. Creating new users, be it your family, friends or colleagues, involves giving them the right permissions and managing what they can do. All this can be done through the GUI and the terminal and in how we will show how.
All commands in this guide will work on most Linux machines. We used an Ubuntu 20.04 installation, but you can run this tutorial on a Raspberry Pi. Some of these instructions are performed through the terminal. You can open a terminal window on most Linux machines by clicking ctrl, alt and t. When working this way, be extra careful when you have multiple users set up to select and delete the correct user accounts!
Add a new Linux user via the GUI
For most, desktop management is more than enough, and fortunately most Linux distributions have it straight.
To add a user via GUI
1 Open up Settings application, scroll down the list and select users section.
2. Click on unlock button and enter your password. Editing these settings requires us to unlock them with a password. This helps to avoid accidents when working with user accounts.
3. Click Add a user button to open a new dialog box.
4. Add the name of the new user. The tool will suggest a username, but you are free to change that. You can either add a password for this user at this stage, or you can allow the user to set their own password when they first log in. When you’re done, click Add to save. You will be prompted to enter your password to confirm the creation of this user.
5. Optional step: Give users extra privileges by clicking administrator section while creating the new user, or by toggling the admin button if the user account has already been created.
6. Sign out and switch users to the new user account. You should notice that they have their own At home directory and that all applications will use the configuration settings for that user.
Delete a Linux user using the GUI
Assuring that user accounts have been deleted is good housekeeping. It removes unnecessary files and, more importantly, removes access to them.
Using the same GUI application, we can delete the Zainab user from our test installation.
1 Open up Settings application, scroll down the list and choose users section.
2. Click on unlock button and enter your password. Editing these settings requires us to unlock them with a password. This helps avoid accidental user deletions from your system.
3. Select the user account you want to remove and click Remove user button. Note that if this user is currently logged in, you will receive a warning that deleting a user while logged in may cause problems.
4. Click Delete Files b to remove the user At home directory. If you haven’t backed up your files yet, click Save Files.
Add a user through the Linux terminal
The GUI is great, but sometimes we have to get our hands dirty in the terminal and from here we can easily manage the users. An ambitious system administrator and Bash script can even automate the process. Adding a user to the system using the command line interface in a terminal is easy.
In the next example we used sudo at the beginning of commands, as they require root or sudo privileges to run. If you are logged in as root, you do not need to add sudo to these commands.
1 Add a new user using adduser team. When prompted enter your password to confirm that you have sudo privileges. The new username must be in lower case.
2. Create password and user data for the new user account. You do not need to fill in all the information. You can leave them blank by pressing Enter key to skip them.
3. Confirm the new user information by typing d and then press Enter. If there is an error, you can enter n to cancel the operation.
sudo adduser jamal
Add a user to a group via the Linux terminal
Group membership is used to ensure that multiple users in a group have basic permissions and privileges. With groups, we can ensure that users in a group have these basic permissions without having to assign them permissions individually.
1 Open a terminal.
2. Add the new user to the sudo group using custom mod team. IN custom mod the command has two arguments. The first is -a and this adds the user. IN d the argument requires the name of the group (s) to which the user must be added.
sudo usermod -aG sudo <username>
Delete a user via the Linux terminal
Deleting a user account using the command line interface is easy. Like the previous addition of a custom example, we need to use sudo or be logged in as root to perform these operations.
1 Use fraudster team with – removal-home argument to remove user and their home directory. Similar to adding a user with adduser we can use fraudster to remove user accounts. Add –removal-home arguments removes the user’s home directory and deletes all their files.
sudo deluser –remove-home <username>
2. Use deluser to delete user without deleting their home directory. Sometimes we may need to remove a user without deleting their home directory and files. To do this, just start fraudster command without added arguments.
sudo deluser <username>
Between the GUI tools and the command line interface, you already have a good collection of basic approaches to managing user accounts, their file content, and group access on most Linux systems.