userdel
Overview
The userdel
command deletes a user account and related files. It removes the user from the system, optionally including their home directory and mail spool.
Syntax
userdel [options] login
Common Options
Option | Description |
---|---|
-f |
Force removal |
-r |
Remove home dir |
-Z |
Remove SELinux |
--help |
Show help |
--version |
Show version |
Affected Files
File | Description |
---|---|
/etc/passwd | User accounts |
/etc/shadow | Secure accounts |
/etc/group | Group accounts |
/home/user | Home directory |
/var/mail/user | Mail spool |
/var/spool/mail/user | Mail directory |
Key Use Cases
- Account removal
- System cleanup
- Security management
- Directory cleanup
- User management
Examples with Explanations
Example 1: Basic Remove
userdel username
Remove user account
Example 2: Full Remove
userdel -r username
Remove with home directory
Example 3: Force Remove
userdel -f username
Force user removal
Common Usage Patterns
Simple delete:
userdel user
Complete removal:
userdel -r user
Force cleanup:
userdel -f -r user
Security Considerations
- Data removal
- File ownership
- Group access
- System security
- Backup importance
Additional Resources
Best Practices
- Backup data
- Check processes
- Verify ownership
- Document removal
- Test completion
User Management
- Account removal
- Data cleanup
- Group handling
- Security update
- System cleanup
Troubleshooting
- Permission denied
- Process running
- File ownership
- Group membership
- Directory issues
Common Issues
- Active processes
- File permissions
- Group ownership
- System files
- Mail spools