deluser
Quick Reference
Command Name:
deluser
Category:
user management
Platform:
linux
Basic Usage:
Common Use Cases
- 1
User management
Remove user accounts from the system safely
- 2
Security maintenance
Remove unused or compromised accounts to maintain system security
- 3
Home directory cleanup
Optionally remove user home directories and mail spools
- 4
Group removal
Remove user groups along with user accounts
Syntax
deluser [options] user deluser --group [options] group
Options
Option | Description |
---|---|
--backup | Backup all files in the user's home directory before removing |
--backup-to DIR | Target directory for backups (default: current directory) |
--backup-suffix SUFFIX | Suffix for backup file (default: ~) |
--force | Force removal, even if the user is still logged in |
--group | Remove a group instead of a user |
--only-if-empty | Only remove a group if it has no members |
--quiet | Suppress informational messages, only report errors |
--remove-all-files | Remove all files owned by the user |
--remove-home | Remove the user's home directory |
--system | Only remove if system user/group |
--help | Display help information and exit |
--version | Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the deluser
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Remove a user sudo deluser john