Userdel Command

What is the Userdel Command?

The userdel command is used to delete a user account from a Linux system. It removes the user from the system and can optionally remove the user's home directory and files.

How Does It Work?

When you use the userdel command, it deletes the specified user account and can also remove the associated home directory and mail spool. However, it does not remove files owned by the user outside of these directories.

Syntax: userdel [options] username

Common Options

Examples

To delete the user "john" without removing the home directory: $ userdel john
To delete the user "alice" and remove her home directory and all files: $ userdel -r alice
To forcefully remove the user "bob" even if they are logged in: $ userdel -f bob

Visual Guide

Below is a visual example of using the userdel command:

Userdel Command Example