Ultimate Guide To Add and Remove Users on AlmaLinux 9

This tutorial intends to teach you an Ultimate Guide To Add and Remove Users on AlmaLinux 9 from the command line. Users who have access to your operating system can do many tasks such as managing, installing, and updating apps, etc. Each user has their own unique ID and password. They can be added to the desired groups in your server and defined to do which tasks you want.

In this guide, you will learn to add new users and add them to a group, and also learn to delete the users on AlmaLinux 9.

Ultimate Guide To Add and Remove Users on AlmaLinux 9

To complete this guide, you must have access to your server a root or non-root user with sudo privileges. For this purpose, you can visit this guide on Initial Server Setup with AlmaLinux 9.

For detailed information to create a new user with sudo privileges, you can follow the steps below.

Step 1 – Create a New User on AlmaLinux 9

At this point, you can create a new user on your server by using the adduser command. For example, we create a new user named orca:

adduser orca

This command automatically creates a home directory for the user named /home/orca. If you want to specify your desired home directory, you must use the -d flag and define your desired path:

useradd orca -d /path/to/home

Step 2 – Add the User to a Specific Group on AlmaLinux 9

You can add your users to your desired groups on AlmaLinux 9. Here we want to add our user to the sudo groups that can have root privileges and run sudo commands.

In AlmaLinux 9, the sudoers group is named wheel. To add the user to the sudoers group, you can use the command below:

usermod -aG wheel orca

This will allow our user orca to run the root privileged commands. To verify it, you can use the following lid command:

lid orca
Output
 wheel(gid=10)
 orca(gid=1000)

You can easily use this command to add your users in the different groups.

Step 3 – Set a Password for the User on AlmaLinux 9

By default, the users you have created, don’t have passwords. You can give a password for them so they can log in to the server by using their own password. To do this, you can use the passwd command. Here we gave our user Orca a password with the command below on AlmaLinux:

passwd orca

You will be asked to enter a new password and verify it.

Output
Changing password for user orca.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Also, you can check your user ID and groups with the command below:

id orca
Output
uid=1000(orca) gid=1000(orca) groups=1000(orca),10(wheel)

Step 4 – Remove Users on AlmaLinux 9

If you plan to remove or delete a specific user from your AlmaLinux 9, you can easily use the userdel command.

For example, to delete the orca user, we run the command below:

userdel orca

This will not remove the home directory of the user. If you want to delete the home directory too, you must use the -r flag in your command. To do this, run the command below:

userdel -r orca

That’s it, you done. These are the basic steps to adding and deleting users on AlmaLinux 9.

You can find more information options and usage by running the help commands:

# useradd --help
# passwd --help
# usermod --help
# userdel --help

Conclusion

At this point, you have learned to use Linux Commands for an Ultimate guide to add and remove users on AlmaLinux 9. You can easily use the useradd command to add a user, and you can use the userdel command to delete your users.

Hope you enjoy it. You may be interested in these articles:

Install Froxlor Server Management on AlmaLinux 9

AlmaLinux vs CloudLinux – Which One is Better For Web Hosting

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!