---
title: "How to Remove a Linux User"
description: "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 “..."
url: https://www.inmotionhosting.com/support/product-guides/self-managed-vps/remove-a-linux-user/
date: 2021-02-03
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Self-Managed VPS Hosting"]
type: post
lang: en
---

# How to Remove a Linux User

You need to know how to remove a Linux user you create on an operating system (OS): [CentOS](https://www.inmotionhosting.com/support/product-guides/vps-hosting/how-to-create-a-new-user-in-centos-7/), [Debian](https://www.inmotionhosting.com/support/product-guides/cloud-server/how-to-create-a-sudo-user-in-debian-8/), [Ubuntu](https://www.inmotionhosting.com/support/product-guides/vps-hosting/how-to-create-a-new-user-in-centos-7/), 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](https://www.inmotionhosting.com/support/product-guides/cloud-server/secure-cloud-server-hosting/) 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](https://www.inmotionhosting.com/cloud-vps).

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)CentOS, Debian, or Ubuntu ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)No Bloatware ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)SSH and Root Access

## Remove a Linux User

[![Use htop after you remove a Linux user's processes](https://www.inmotionhosting.com/support/wp-content/uploads/2019/07/htop-terminal-1.png)](https://www.inmotionhosting.com/support/server/linux/stop-processes-in-htop/)

1. [Log into SSH](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/) as [root](https://www.inmotionhosting.com/support/amp/obtain-root-access/).
2. Prevent the user from being able to login and start new processes:

   ```
   sudo passwd --lock user1
   ```

   You may receive a notification stating “passwd: password expiry information changed.”

3. Kill the user’s processes with one of the following commands:

   ```
   sudo pkill -KILL -u user1
   ```

   ```
   sudo killall -9 -u user1
   ```

4. Ensure the user is no longer running any processes. You can use many process managers such as`ps -aux`, top, or [htop](https://www.inmotionhosting.com/support/server/linux/stop-processes-in-htop/).
5. (Optional) You may benefit from [archiving the user directory](https://www.inmotionhosting.com/support/website/tar-command-basic-archiving/) before removing it. In other cases, it may be better to simply create a server [snapshot](https://www.inmotionhosting.com/support/product-guides/vps-hosting/snapshots/) or full backup instead. You should also recommend the user to backup their own data from the server and to a [PC backup solution](https://www.techadvisor.co.uk/test-centre/software/best-backup-software-3647678/) for their own safekeeping.
6. Check for [cron jobs](https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job/) maintained by the user:

   ```
   sudo crontab -u user1 -l
   ```

7. Remove the user’s cron jobs:

   ```
   sudo crontab -r -u user1
   ```

8. 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):

   ```
   sudo userdel --remove user1
   ```

   ```
   sudo userdel -r user1
   ```

   Remove the user account even if it’s logged in and has processes running:

   ```
   sudo userdel -f user1
   ```

   ```
   sudo userdel --force user1
   ```

   Debian:

   ```
   sudo deluser --remove-home user1
   ```


Learn more about server management with our [Cloud Server Product Guide](https://www.inmotionhosting.com/support/product-guides/cloud-server/).
