Table of Contents
You need to know how to remove a Linux user you create on an operating system (OS): CentOS, Debian, Ubuntu, etc. Hopefully, you’re using other user management controls such as least privilege and “need to know” already. Removing unneeded Linux users is an easy way to secure your cloud server from unauthorized access when someone takes a mandatory vacation or is terminated from your organization.
Below we’ll cover how to remove a Linux user on CentOS, Debian, and Ubuntu.
If you don’t need cPanel, don't pay for it. Only pay for what you need with our scalable Cloud VPS Hosting.
CentOS, Debian, or Ubuntu
No Bloatware
SSH and Root Access
Remove a Linux User
- Log into SSH as root.
- Prevent the user from being able to login and start new processes:
You may receive a notification stating “passwd: password expiry information changed.” - Kill the user’s processes with one of the following commands:
- Ensure the user is no longer running any processes. You can use many process managers such as
ps -aux
, top, or htop. - (Optional) You may benefit from archiving the user directory before removing it. In other cases, it may be better to simply create a server snapshot or full backup instead. You should also recommend the user to backup their own data from the server and to a PC backup solution for their own safekeeping.
- Check for cron jobs maintained by the user:
- Remove the user’s cron jobs:
- Finally, remove the user’s files on the system. The recommended command depends on your Linux distribution.
CentOS and Arch (remove the CentOS user’s home directory):
Remove the user account even if it’s logged in and has processes running:
Debian:
Learn more about server management with our Cloud Server Product Guide.