deluser 命令在 CentOS 系统中用于删除用户账户。以下是 deluser 命令的一些常用参数:
deluser [用户名]:删除指定的用户账户。deluser --remove-home [用户名]:删除用户账户并同时删除其主目录。deluser --remove-all-files [用户名]:删除用户账户及其所有文件(包括主目录)。--disabled-login:禁用用户的登录功能。--gecos [信息]:更新用户的 GECOS 字段(通常用于存储用户的完整名称和其他信息)。--group [组名]:将用户从指定的组中移除。--home [新主目录]:更改用户的主目录。--shell [新Shell]:更改用户的默认Shell。--uid [新UID]:更改用户的UID。--gid [新GID]:更改用户的GID。--no-create-home:删除用户账户但不创建新的主目录。--password [密码]:设置用户的密码(通常用于锁定或解锁账户)。--remove-group:删除用户所属的所有组。--remove-from-group [组名]:将用户从指定的组中移除。删除用户 john 并删除其主目录:
deluser --remove-home john
删除用户 jane 并禁用其登录功能:
deluser --disabled-login jane
删除用户 doe 并将其从 developers 组中移除:
deluser doe --group developers
更改用户 alice 的主目录为 /home/alice_new:
deluser alice --home /home/alice_new
锁定用户 bob 的账户:
deluser bob --password '*'
deluser 命令删除用户账户时,请确保备份所有重要数据,因为删除操作是不可逆的。sudo)才能执行。通过这些参数,你可以灵活地管理 CentOS 系统中的用户账户。