Casbay Knowledge Base

Search our articles or browse by category below

HOW TO: Remove (Delete) a User on CentOS 7

Last modified: October 1, 2022
You are here:
Estimated reading time: 1 min

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.

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

For a refresher on editing files with vim see: Overview of the Vim Text Editor


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.

Was this article helpful?
Dislike 0
Previous: Improve Linux VPS Server Management By Learning Basic Tee Commands
Next: How to Install MetaTrader 5 in Windows VPS