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.

How to change Left & Right mouse buttons on Windows 10 PC
It's quite a norm that all computer mouse devices are ergonomically designed for right-handed users. But there are mouse devices available which are s...
Emulate Mouse clicks by hovering using Clickless Mouse in Windows 10
Using a mouse or keyboard in the wrong posture of excessive usage can result in a lot of health issues, including strain, carpal tunnel syndrome, and ...
Add Mouse gestures to Windows 10 using these free tools
In recent years computers and operating systems have greatly evolved. There was a time when users had to use commands to navigate through file manager...