deluser 命令在 CentOS 系统中用于删除用户账户
deluser 命令的基本语法如下:
deluser [选项] 用户名 [用户组]
其中,选项 可以是以下之一:
-f 或 --force:强制删除用户,即使该用户有登录会话或正在运行进程。-r 或 --remove:删除用户的主目录及其内容。-s 或 --shell:将用户的默认 shell 更改为 /sbin/nologin,以防止用户登录。用户名 是要删除的用户账户的名称。
用户组(可选)是要删除的用户所属的主要用户组。如果不指定此选项,系统将删除用户及其主要用户组。
以下是一些使用 deluser 命令的示例:
exampleuser 的用户,并将其主要用户组设置为 examplegroup:deluser exampleuser examplegroup
exampleuser 的用户,即使该用户有登录会话:deluser -f exampleuser
exampleuser 的用户,并删除其主目录及其内容:deluser -r exampleuser
exampleuser 的用户的默认 shell 更改为 /sbin/nologin:deluser -s /sbin/nologin exampleuser
请注意,在使用 deluser 命令时要小心,因为删除用户账户将导致与该用户相关的所有文件和资源丢失。在执行此操作之前,请确保已备份所有重要数据。