Need help? Chat now!
Search results for:
Table of Contents
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 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 remove the unused account. In this article, we will show you how to remove a user account from an Ubuntu server.
Before we get started, you'll need to log in to your server via SSH. If you're not certain how to do this, then not 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 can remove 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:
deluser --remove-home username_to_remove_here
If this user was previously configured with sudo access, which is covered for Ubuntu in the article: Create a Sudo User (Ubuntu), removing this user from the sudoers file is advisable. 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 delete the entry for the user you recently removed.
root ALL=(ALL:ALL) ALL username_to_remove_here ALL=(ALL:ALL) ALL #REMOVE THIS ENTRY!
If everything went successfully, the user account should now be completely removed from your server!
Written by Michael Brower / June 22, 2017