[root@centos8~]# userdel --help
用法:userdel [选项] 登录
选项:
-f,--force force some actions that would fail otherwise
e.g. removal of user still logged in
or files, even if not owned by the user
-h,--help 显示此帮助信息并推出
-r,--remove 删除主目录和邮件池
-R,--root CHROOT_DIR chroot 到的目录
-Z,--selinux-user 为用户删除所有的 SELinux 用户映射
删除用户:userdel 【选项】【用户名】
-r :表示删除用户的同时,删除其家目录;
补充:启动中的用户无法删除成功,这时候只要 kill 掉它即可。
1、查看账号密码过期时间等信息
[root@centos7~]# chage -l test
Last password change :Apr27,2021【最近一次修改密码的时间】
Password expires :Jul26,2021【密码过期时间】
Password inactive : never【密码失效时间】
Account expires : never【账户过期时间】
Minimum number of days between password change :0 【两次改变密码之间相距最小天数】
Maximum number of days between password change :90 【两次密码改变密码相距最大天数】
Number of days of warning before password expires :15 【密码过期前开始警告的天数】
2、设置密码过期时间
[root@centos7~]# passwd -x 90 test
Adjusting aging data for user test.
passwd:Success[root@centos7~]# chage -l test
Last password change :Apr27,2021Password expires :Jul26,2021Password inactive : never
Account expires : never
Minimum number of days between password change :0Maximum number of days between password change :90Number of days of warning before password expires :73、设置用户test密码永不过期
root@centos7~]# chage -M99999 test
[root@centos7~]# chage -l test
Last password change :Apr27,2021Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :0Maximum number of days between password change :99999Number of days of warning before password expires :74、设置test用户过期时间
[root@centos7~]# chage -E60 test
[root@centos7~]# chage -l test
Last password change :Apr27,2021Password expires : never
Password inactive : never
Account expires :Mar02,1970Minimum number of days between password change :0Maximum number of days between password change :99999Number of days of warning before password expires :75、 #把 test 的账号失效时间设置为 从不失效
[root@centos7~]# chage -E-1 test