Wesbytes Knowledge Base

Search our articles or browse by category below

How to Remove a User on CentOS 7

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

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.

Linux VPS Server

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

Was this article helpful?
Dislike 0
Views: 22