$linuxjunkies
>

userdel(8)

Delete a user account and optionally remove their home directory and mail spool.

UbuntuDebianFedoraArch

Synopsis

userdel [OPTION]... LOGIN

Description

userdel modifies the system account files, deleting all entries that refer to LOGIN. It must be invoked as root or with sudo. The named user must exist.

By default, the user's home directory and mail spool are preserved. Use -r to remove them along with the account. If the user is currently logged in or running processes, userdel will fail unless -f is specified.

Common options

FlagWhat it does
-rRemove the user's home directory and mail spool entirely
-fForce deletion even if user is still logged in or has running processes
-ZRemove any SELinux user mapping for the user

Examples

Delete the user 'olduser' but leave their home directory and mail intact

sudo userdel olduser

Delete 'olduser' and remove their entire home directory and mail spool

sudo userdel -r olduser

Force delete 'activeuser' even if they're currently logged in

sudo userdel -f activeuser

Force delete 'tempuser' and completely remove their home directory

sudo userdel -r -f tempuser

Related commands