userdel(8)
Delete a user account and optionally remove their home directory and mail spool.
UbuntuDebianFedoraArch
Synopsis
userdel [OPTION]... LOGINDescription
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
| Flag | What it does |
|---|---|
-r | Remove the user's home directory and mail spool entirely |
-f | Force deletion even if user is still logged in or has running processes |
-Z | Remove any SELinux user mapping for the user |
Examples
Delete the user 'olduser' but leave their home directory and mail intact
sudo userdel olduserDelete 'olduser' and remove their entire home directory and mail spool
sudo userdel -r olduserForce delete 'activeuser' even if they're currently logged in
sudo userdel -f activeuserForce delete 'tempuser' and completely remove their home directory
sudo userdel -r -f tempuser