How to Delete a User in Linux

linux delete user

As a Linux system administrator, you may need to create and delete users on your system. Deleting a user is a task that you may need to perform from time to time. This article will guide you on how to delete a user in Linux.

What is a User in Linux?

In Linux, a user is a person or a process that interacts with the system. Each user has a unique username and user ID (UID) assigned to them. The UID is a numeric value that identifies a user on the system. Users can be assigned to different groups, which determine their access to files, directories, and system resources.

How to Delete a User in Linux

To delete a user in Linux, you need to follow these steps:

Step 1: Log in as Root

To delete a user in Linux, you need to have administrative privileges. Log in as root or a user with sudo privileges.

sudo su

Step 2: Check User Information

Before deleting a user, you should check their information to ensure that you are deleting the correct user. You can use the id command to check the user’s UID and group ID (GID).

id username

Step 3: Delete User

To delete a user in Linux, use the userdel command followed by the username you want to delete.

userdel username

The userdel command removes the user’s account and home directory. If you want to remove the user’s home directory and mail spool, use the -r option.

userdel -r username

Step 4: Verify User Deletion

To verify that the user has been deleted, use the id command again.

id username

If the user has been deleted, the system will return an error message saying that the user does not exist.


Deleting a user in Linux is a straightforward process. By following the steps outlined in this guide, you can delete a user in Linux with ease. Remember to double-check the user’s information before deleting them and use the -r option if you want to remove their home directory and mail spool.