1. Introduction command
userdel (user delete) command is a system administrator commands for deleting user accounts and related documents.
In fact userdel command actually modifies the user account of the file system / etc / passwd, / etc / shadow and / etc / group file, which is a Linux system "all file operations are" thinking coincided.
It is noteworthy that, if you want to delete the user-related processes are running, userdel command normally does not delete a user account. If you do need to delete, you can terminate user processes, then perform userdel command to delete. But userdel command also provides a parameter to face this kind of situation, namely the -f option.
2. Command Format
userdel [options] LOGIN
If left option, delete user accounts only, without deleting the relevant files.
3. Option Description
-f, --force
强制删除用户,即使用户当前已登录
-h, --help
显示帮助信息并推出
-r, --remove
删除用户的同时删除与用户相关的所有文件,比如删除主目录和邮件池
-R, --root CHROOT_DIR
在 CHROOT_DIR 目录中应用更改并使用 CHROOT_DIR 目录中的配置文件
-Z, --selinux-user
为用户删除所有的 SELinux 用户映射
4. Common examples
(1) delete a user without deleting their home directories and files.
userdel tom
(2) delete users, delete the home directory and mail spool.
userdel -r tom
Do not remove easily with the -r option, it will delete all user while the user's files and directories, remember there are important files if the user directory, make a backup before deleting.
(3) forcibly remove users.
userdel -f tom
references
[1] userdel (8) Manual
[2] . CSDN [Linux] step by step learning Linux - userdel command (84)