Hostwinds Tutorials

Search results for:


Table of Contents


How To Delete a User in CentOS 7
Delete User While Preserving Files
Delete User and Files

How to Delete a User (CentOS 7)

Tags: CentOS Web Panel 

How To Delete a User in CentOS 7
Delete User While Preserving Files
Delete User and Files

You may find that at some point, you have a user account that is no longer needed and needs to be removed from your server. Perhaps a contractor that you have hired has completed their work, or it is simply a test account that has served its purpose. Regardless of the circumstance, you can delete any unnecessary user's from your server. In this article, we will show you how to delete user accounts on a CentOS 7 server.

How To Delete a User in CentOS 7

Before we begin, you'll need to log in to your server via SSH. If this is not something that you're familiar with, you can refer to the following article, which covers Connecting to Your Server via SSH. There are a few methods that you can utilize to remove a user's account.

Delete User While Preserving Files

If you'd like to remove the user's account but want to keep the files associated with the account. You'd use the following as the root or sudo user. If you're using a sudo user make sure you add sudo before the command:

userdel username_to_delete_here

This would remove the actual user, preventing them from accessing your server using the login credentials associated with that account, but keep all of their files.

Delete User and Files

If you wanted to remove all files including their home directory and the user account itself, you could do so via the following command issued as the root or sudo user. If you're using a sudo user, please ensure that you add sudo before the command:

userdel -r username_to_delete_here

This would effectively and remove all traces of the user from your server. Note that without a backup, the files are permanently removed.

Written by Michael Brower  /  June 22, 2017