Search The Hostwinds Guides Knowledge Base

How to Delete a User (Ubuntu)

Adding a new user is a simple but essential part of managing a Linux based server, such as Ubuntu, which we previously covered in the article: How to create a new user (Ubuntu). But what about removing a user that you no longer need? You could just leave the account there, however this may prove to be a security breach waiting to happen or perhaps you’d like to free up the space that the unused account is taking up. Either way the best solution is to simply remove the unused account. In this article we will show you how to remove a user account from an Ubuntu server.

 

How to delete a user in Ubuntu

Before we get started you’ll need to login to your server via SSH. If you’re not certain how to do this then not to worry as we have written a guide that will show you the ins and outs of: Connecting to Your Server via SSH. Once connected you may move on to the rest of this article.

 

When removing the user, you have the option of removing just the user, or the user as well as their home folder/files, you’d use the following as the root or sudo user to remove the user only. If you’re using a sudo user please ensure that you add sudo before the command:

 

 

To remove the user and their associated files you’d 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:

 

 

If this user was previously configured with sudo access, which is covered for Ubuntu in the article: Create a Sudo User (Ubuntu), it is advisable to remove this user from the sudoers file. You can do just that by issuing the following command as the root or sudo user. If you’re using a sudo user please ensure that you add sudo before the command:

 

 

You’d then need to locate the line that looks similar to the following and deleting the entry for the user that you recently removed.

 

 

 

If everything went successfully the user account should now be completely removed from your server!