Account
Categories

userdel command


Definition:

To remove a user from your system, type this command, and the user will be deleted after execution.

Syntax:

userdel [options] username

Options:

-r → This option deletes the user and also removes their home directory along with all files inside it.

Example:

userdel -r username

-f → This option forcefully deletes the user, even if they are logged in or have running processes.

Example:

userdel -f username

-Z → If SELinux is enabled, this option deletes any SELinux user mapping connected to that user.

Example:

userdel -Z username

Example:

userdel prabha

Output:

Prabha was deleted successfully.