Linux命令 - userdel命令
Linux中 userdel 命令用于删除用户帐号。
1.语法:
userdel [参数] [用户帐号]
2.功能:
可删除用户帐号与相关的文件。若不加参数,则仅删除用户帐号,而不删除相关文件。
3.参数:
-r 删除用户登入目录以及目录中所有文件。
4.常用范例:
例一:删除用户但保存用户主目录
命令:userdel testuser1
[root@localhost home]# ll
总用量 0
drwx------. 3 esther esther 78 5月 12 14:23 esther
drwx------. 4 testuser testuser 113 5月 20 15:13 testuser
drwx------. 3 testuser1 testuser1 78 5月 20 15:12 testuser1
[root@localhost home]# userdel testuser1
[root@localhost home]# ll
总用量 0
drwx------. 3 esther esther 78 5月 12 14:23 esther
drwx------. 4 testuser testuser 113 5月 20 15:13 testuser
drwx------. 3 1002 1002 78 5月 20 15:12 testuser1
例二:删除用户和用户主目录
命令: userdel -r testuser
[root@localhost home]# ll
总用量 0
drwx------. 3 esther esther 78 5月 12 14:23 esther
drwx------. 4 testuser testuser 113 5月 20 15:13 testuser
drwx------. 3 1002 1002 78 5月 20 15:12 testuser1
[root@localhost home]# userdel -r testuser
[root@localhost home]# ll
总用量 0
drwx------. 3 esther esther 78 5月 12 14:23 esther
drwx------. 3 1002 1002 78 5月 20 15:12 testuser1