userdel
user managementLinux/Unix
The userdel command is one of the most frequently used commands in Linux/Unix-like operating systems. userdel Delete a user account and related files
Quick Reference
Command Name:
userdel
Category:
user management
Platform:
Linux/Unix
Basic Usage:
userdel [options] [arguments]
Common Use Cases
Syntax
userdel [options] LOGIN
Options
Option | Description |
---|---|
-f, --force |
Force removal of files, even if not owned by user |
-h, --help |
Display help message and exit |
-r, --remove |
Remove home directory and mail spool |
-R, --root CHROOT_DIR |
Apply changes in CHROOT_DIR directory |
-P, --prefix PREFIX_DIR |
Apply changes in PREFIX_DIR directory |
-Z, --selinux-user |
Remove any SELinux user mapping for the user's login |
Examples
How to Use These Examples
The examples below show common ways to use the userdel
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Delete a user account
sudo userdel johndoe