Permissions
userdel
Delete a local user account.
useraccountdeleteadminhome
Additional Notes
userdel removes a local user account from the system account database. It can optionally remove the user's home directory and mail spool.
Deleting users should be done carefully because files owned by the deleted UID may remain on disk.
Syntax
userdel [options] username
Parameters
options: Flags that change howuserdelbehaves.user: User account affected by the command.group: Group account affected by the command.file: File or directory whose ownership, mode, or access policy is being changed.
Common Options
-r,--remove: Remove the user's home directory and mail spool.-f,--force: Force removal in some cases.
Examples
sudo userdel olduser
Remove the account but keep files.
sudo userdel -r olduser
Remove the account and its home directory.
find / -nouser -ls 2>/dev/null
Find files that no longer have a valid owner.
Practical Notes
- Back up important user data before deletion.
- Check running processes before removing active service users.
userdeldoes not necessarily remove every file the user owns.- Avoid
-funless you understand why normal deletion failed.