Linux查看用户过期时间及禁用用户登陆

修改用户为非登陆类型用户

[root@localhost]#usermod haha-s /sbin/nologin
[root@localhost]# cat /etc/passwd

haha:x:1002:1002::/home/haha:/sbin/nologin
 

查看用户密码过期时间

[root@localhost]# chage -l haha
Last password change                    : Nov 05, 2021
Password expires                    : never
Password inactive                    : never
Account expires                        : never //密码永不过期
Minimum number of days between password change        : 0
Maximum number of days between password change        : 99999
Number of days of warning before password expires    : 7

修改密码过期时间为1,真实时间为an 02, 1970 
[root@localhost]# usermod --expiredate 1 haha

[root@localhost]# chage -l haha

Last password change                    : Dec 09, 2019
Password expires                    : never
Password inactive                    : never
Account expires                        : Jan 02, 1970 
Minimum number of days between password change        : 0
Maximum number of days between password change        : 99999
Number of days of warning before password expires    : 7
 

你可能感兴趣的:(linux,服务器,运维)