linux新用户密码90天过期 修改永不过期

    技术2022-07-11  102

    方法一:

    使用root用户

    vim /etc/shadow

    vim /etc/shadow

    找到需要修改的用户,将倒数第三个的90改为99999

    :wq!强制保存退出

    方法二:

       查看密码过期时间,现在是90天   

    [root@01 ~]# chage -l “用户名” Last password change     : Jul 10, 2020 Password expires     : Oct 08, 2019 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    : 10

    用命令修改过期时间为永久,然后查看Password expires   : never   和  Maximum number of days between password change  : 99999修改成功

    [root@01 ~]# chage “用户名” -M 99999 [root@01 ~]# chage “用户名” -l Last password change                    : Jul 10, 2019 Password expires                    : never Password inactive                    : never Account expires                        : Oct 16, 2243 Minimum number of days between password change        : 0 Maximum number of days between password change        : 99999 Number of days of warning before password expires    : 10

    chage:密码失效 通过此命令来管理   参数:   -m 密码可更改的最小天数。为零时代表任何时候都可以更改密码。   -M 密码保持有效的最大天数。   -W 用户密码到期前,提前收到警告信息的天数。   -E 帐号到期的日期。过了这天,此帐号将不可用。   -d 上一次更改的日期   -I 停滞时期。如果一个密码已过期这些天,那么此帐号将不可用。   -l 例出当前的设置。由非特权用户来确定他们的密码或帐号何时过期。

    [root@localhost ~]# chage test -l      #查看用户密码设定情况 最近一次密码修改时间                                    :  6月 27, 2020 密码过期时间                                    : 从不 密码失效时间                                    : 从不 帐户过期时间                                            : 从不 两次改变密码之间相距的最小天数          :-1 两次改变密码之间相距的最大天数          :-1 在密码过期之前警告的天数        :-1   [root@localhost ~]# chage test -M 90        #密码有效期90天   [root@localhost ~]# chage test -d 0        #强制用户登陆时修改口令   [root@localhost ~]# chage test  -d 0 -m 0 -M 90 -W 15 #强制用户下次登陆时修改密码,并且设置密码最低有效期0和最高有限期90,提前15天发警报提示   [root@localhost ~]# chage test  -E '2020-09-30'  # test这个账号的有效期是2020-09-30

     

    Processed: 0.012, SQL: 9