When to use userdel
Use userdel only for a known account that is no longer needed. Review running processes, scheduled work and owned files first; removing an account is not a complete audit of that identity's data.
Syntax
userdel [PARAMETERS] NAMESquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Check identity before deleting
id demo-userThe account's identity is inspected before any removal.
Check user processes
pgrep -u demo-user -aProcesses belonging to that account are listed so active work can be identified.
Delete the selected test account
sudo userdel demo-userThe account entry is removed without requesting recursive deletion of its home directory.
Notes and limitations
- Deleting an account may leave files with the same number UID. Check owners and backups.
- The -r option deletes data; don't use it without checking your home directory separately.
Common questions and troubleshooting
Will this remove every file the user owned?
No. Files elsewhere can remain with the numeric owner ID. Inventory and reassign or archive data deliberately.
Why must numeric IDs be considered after deletion?
If an ID is later reused, old files can appear owned by the new account. Resolve retained ownership as part of account retirement.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man userdel.