CentOS

How to Create and Delete Users on CentOS 8

How to Create and Delete Users on CentOS 8

User management is much needed and must-know technique for a Linux server administrator. A Linux administrator often needs to create and grant different privileges and permissions to different users. This post will perform a couple of tasks like creating and deleting the user on the CentOS 8 Operating system.

As you know, the creation and deletion of a user is an administrative type of task, and for performing such tasks, you must log in as a root user or execute all the commands with the sudo privileges. Let's start and see how to add or create a user in the CentOS 8 system.

Creating a user in CentOS 8

The user can be added or created in the CentOS 8 system using the “adduser” command in the terminal. For example, if we want to create a user with the name “John”, the command would be like this:

$ sudo adduser john


After successfully creating the user, it's time to assign the password to the newly created user. You can simply assign the password using the “passwd” command:

$ sudo passwd john

After running the above command, it will prompt for the password, so provide the password twice, and the password will be set for the newly created user.

Granting Sudo privileges to the User

Suppose you want to give administrative rights to this newly created user. In that case, you have to add the user in the wheel group (the group which grants sudo privileges to all of its users automatically). To add the user to the wheel group, type the command given below:

$ sudo usermod -aG wheel john

The administrative rights are granted successfully to the newly created user as well. Now let's see how to delete a user in the CentOS 8 Operating system.

Deletion of a user in CentOS 8

Now, if you want to delete any user from the CentOS 8 Operating system due to any reason, either that user is unnecessary or not needed anymore. For example, if we want to delete the user “john”, we can delete such a user using the “userdel” command:

$ sudo userdel -r john

The “-r” flag in the above-given command is for deleting the user's home directory. If you do not want to delete the user's home directory, you can run the above command without the “-r” flag.

This is it; the user is deleted successfully as well from the CentOS 8 Operating system.

Conclusion

This post explains user creation, granting privileges to the user, and deleting a user from the CentOS 8 Operating system. Users with different privileges have a lot to do while managing the Linux servers, and after reading this post, you can manage the users well on CentOS 8 Operating system.

Встановіть останню стратегічну гру OpenRA на Ubuntu Linux
OpenRA - це ігровий движок Libre / Free Real Time Strategy, який відтворює ранні ігри Вествуда, такі як класичний Command & Conquer: Red Alert. Пошире...
Встановіть найновіший емулятор Dolphin для Gamecube & Wii на Linux
Емулятор Dolphin дозволяє грати у вибрані вами ігри Gamecube та Wii на персональних комп’ютерах Linux (ПК). Будучи вільно доступним і відкритим ігров...
Як використовувати GameConqueror Cheat Engine в Linux
Стаття висвітлює посібник із використання механізму читів GameConqueror в Linux. Багато користувачів, які грають у ігри в Windows, часто використовуют...