userdel
Linux · Users and permissions · reference only
What it does
Deletes a user account from the system. With -r it also removes the home directory and the mail spool.
Syntax
userdel [opciones] usuario
Options and parameters
-rAlso removes the user's home directory and mail spool.
-fForces removal even if the user is logged in; use with care.
-R DIRApplies the changes inside the given root directory (chroot), useful for system images.
-ZAlso removes the user's SELinux mapping.
-hShows help and exits.
Usage examples
sudo userdel anaDeletes the ana account but keeps her /home/ana directory.
sudo userdel -r anaDeletes the account and its whole home directory.
getent passwd anaChecks the account is gone: it prints nothing if the deletion worked.
sudo userdel -f pruebasForces the removal of an account even if it is in use.
Notes and common mistakes
- Without -r the user's files stay on disk and keep an orphan UID.
- A user with running processes cannot be deleted unless you use -f.
- On Debian and Ubuntu, deluser is a friendlier alternative.