The account with the sudo privileges can run the system as an administrator that a normal user cannot. These privileges allow the user to act as a root user through which the user can perform all the administrative tasks or commands.
It is not compulsory to assign the root password to every user. If you assign them sudo permissions, they will have access to perform all the operations without knowing the root password.
Similarly, you can get back the sudo permissions from the users by deleting their accounts. Follow the guide to learn multiple approaches:
How to Delete User from Sudoers File on CentOS:
When a user is added to the device, the “sudoers” file keeps the record. The sudoers file is used to manage the user’s record, including who the user is, what functions the user performed, and where, etc.
Several ways are introduced to delete users from the centOS. By following the guide, you will learn two approaches:
- Through the userdel command
- Through the sudoers file
How to delete user from CentOS using the “userdel” command:
Using the “userdel” command, it is very simple to remove a user from the account.
Open a terminal and type:
Suppose, to delete the user account “linuxhint,” the command would be:
To delete a user account through the “userdel” command is not enough sometimes; there might be a case that its respective files or data could be saved in the home directory.
So, to remove a user with its associated data from the home directory, use the “-r” option:
How to delete user from CentOS using sudoers file:
When we remove the user from the CentOS, it is possible that the sudoers file still has its information.
So, run the “visudo” command to find the sudoers file:
Scroll down the file until you get the given line:
Right after this line, you will see the user’s name entry:
Remove this line, and the user will no longer be found in the sudo group.
While using CentOS 8, adding and removing other users are the most common tasks you should know about. We need to add users for several reasons, but sometimes, we have to take privileges back due to security reasons. Through the sudo privileges, one can access run administrative tasks without knowing the root password even.
The guide was discussing how you can delete a user from the sudeors file. Although a user can be deleted several ways, we have discussed the two simple approaches, using the userdel command and sudoers file.