You may find that sometimes you have a user account that is no longer needed and needs to be removed from your server. It may due to a completion of work done by the contractor that you have hired, or it is simply a test account that has served its purpose. Regardless of the circumstance, you can delete any users which you find unnecessary from your server. In this article, we will guide you on removing a user on CentOS 7.
PleaseĀ follow these instructionsĀ that are intended specifically to delete/ remove users on your CentOS 7.
Step 1: Delete the User
Itās just one simple command to add a user. In this case, weāre adding a user calledĀ mynewuser:
userdel mynewuser
If you want to remove all of the files for the user, then useĀ -r:
userdel -r mynewuser
Step 2: Remove Root Privileges to the User
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
mynewuser ALL=(ALL) ALL
In this case, we’re removing root privileges from the user mynewuser. Remove the following:
mynewuser ALL=(ALL) ALL
Then, exit and save the file with the command:wq