• 如何使用change命令改变密码的属性


    使用chage更改用户密码密码使用情况

    -d //设置最近一次更改密码时间, 0下次登陆系统强制修改密码
    -m //设置用户两次改变密码之间使用"最小天数"
    -M //设置用户两次改变密码之间使用"最大天数"
    -W //设置密码更改警告时间 将过期警告天数设为“警告天数”
    -I //设置密码过期天数后, 密码为失效状态
    -E //设置用户过期时间, 账户失效后无法登陆
    -l //显示用户信息
    
    
    #修改时间为2014年08月31日,和图中时间匹配,方便后续验证
    [root@xuliangwei ~]# date -s '20140831'
    Sun Aug 31 00:00:00 CST 2014
    [root@xuliangwei ~]# date
    Sun Aug 31 00:00:01 CST 2014
    [root@xuliangwei ~]# usereadd bgx1
    [root@xuliangwei ~]# echo "123" |passwd --stdin bgx1
    [root@xuliangwei ~]# tail -1 /etc/shadow
    bgx1:!!:16312:0:99999:7:::
    
    
    #设置最近一次修改密码时间
    [root@xuliangwei ~]# chage -d "2014-09-01" bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:0:99999:7:::
    
    #设置最短使用密码时间
    [root@xuliangwei ~]# chage -m 2 bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:99999:7:::
    
    #设置密码最长使用时间
    [root@xuliangwei ~]# chage -M 15 bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:15:7:::
    
    #设置密码警告时间
    [root@xuliangwei ~]# chage -W 6 bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:15:6:::
    [root@xuliangwei ~]# chage -W 7 bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:15:7:::
    
    #设置密码过期时间
    [root@xuliangwei ~]# chage -I 5 bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:15:6:5::
    
    #设置用户过期时间
    [root@xuliangwei ~]# chage -E "20115-08-31" bgx1
    [root@xuliangwei ~]# tail -n1 /etc/shadow
    bgx1:!!:16314:2:15:6:5:6627567:
    
    [root@xuliangwei ~]# chage -l bgx1
    Last password change			: Sep 01, 2014              #最近一次更改密码时间
    Password expires				: Sep 16, 2014      #密码过期时间
    Password inactive				: Sep 21, 2014      #密码失效时间
    Account expires					: Aug 31, 2015      #用户失效时间
    Minimum number of days between password change      : 2     #密码最短使用时间
    Maximum number of days between password change      : 15   #密码最长使用时间
    Number of days of warning before password expires   : 7        #密码过期前警告天数
    
    
    
    #如何验证,只调整时间为如下进行验证:
    1.验证普通用户是否能修改密码, 不需要调整时间。
    2.普通用户登陆系统后, 会提示警告密码还剩多少天过期
    [root@xuliangwei ~]# date -s "2014-09-12"
    
    3.普通用户登陆系统后, 强制要求修改密码
    [root@xuliangwei ~]# date -s "2014-09-18"
    
    4.普通用户登陆系统后, 提示账户已过期
    [root@xuliangwei ~]# date -s "2014-09-23"
    
  • 相关阅读:
    python-scapy学习笔记-(1)
    python系统性能模块笔记
    Python爬虫总结
    pm2的的常用命令及用法
    Javascript的map与forEach的区别
    对MVVM思想的在认识
    RN的打包
    undefined与null的区别
    rem与em的区别
    JS的函数参数传递为值传递
  • 原文地址:https://www.cnblogs.com/xuliangwei/p/10679004.html
Copyright © 2020-2023  润新知