HOW TO: Remove (Delete) a User on CentOS 7
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.
userdel mynewuser
If you want to remove all of the files for the user, then use -r:
userdel -r mynewuser
For a refresher on editing files with vim see: Overview of the Vim Text Editor
visudo
Find the following code:
## 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 .
There are some articles on the topic CentOS which we think may be helpful for you. If you are interested, visit here to find out more.