命令简介:

  该命令用于密码时效管理。它可以修改账号和密码的有效期。对于chage命令的描述如下所示:

  The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password

命令语法:

  chage [options] user

命令参数:

参数

描叙

-d

指定密码最后修改日期

-E

密码到期的日期,过了这天,此账号将不可用。0表示马上过期,-1表示永不过期。

-h

显示帮助信息并退出

-I

密码过期后,锁定账号的天数

-l

列出用户以及密码的有效期

-m

密码可以更改的最小天数。为零代表任何时候都可以更改密码。

-M

密码保持有效的最大天数。

-W

密码过期前,提前收到警告信息的天数。

使用示例:

1: 查看chage命令的帮助信息

[root@DB-Server ~]#man chage
[root@DB-Server ~]# info chage
[root@DB-Server ~]# chage -h
Usage: chage [options] user Options:
-d, --lastday LAST_DAY set last password change to LAST_DAY
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, --help display this help message and exit
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --list show account aging information
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, --maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS

2:查看mysql用户以及密码的有效期

[root@DB-Server ~]# chage -l mysql
Last password change : Mar ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : -
Maximum number of days between password change : -
Number of days of warning before password expires : -

3:设置mysql用户60天后密码过期,至少7天后才能修改密码,密码过期前7天开始收到告警信息。

[root@DB-Server ~]# chage -M  -m  -W  mysql
You have new mail in /var/spool/mail/root
[root@DB-Server ~]# chage -l mysql
Last password change : Mar ,
Password expires : May ,
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :

4:强制新建用户第一次登陆时修改密码

[root@DB-Server home]# useradd test
[root@DB-Server home]# passwd test
Changing password for user test.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@DB-Server home]# chage -d test
You have new mail in /var/spool/mail/root
[root@DB-Server home]# chage -l test
Last password change : password must be changed
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :  

每天一个Linux命令之:chage的更多相关文章

  1. 每天一个 Linux 命令(21):find命令之xargs

    在使用 find命令的-exec选项处理匹配到的文件时, find命令将所有匹配到的文件一起传递给exec执行.但有些系统对能够传递给exec的命令长度有限制,这样在find命令运行几分钟之后,就会出 ...

  2. 每天一个linux命令(25):linux文件属性详解

    Linux 文件或目录的属性主要包括:文件或目录的节点.种类.权限模式.链接数量.所归属的用户和用户组.最近访问或修改的时间等内容.具体情况如下: 命令: ls -lih 输出: [root@loca ...

  3. 每天一个linux命令(46):vmstat命令

    vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可对操作系统的虚拟内存.进程.CPU活动进行监控.他是对系统的整体情况进行统计,不足之处是无法对某个进程进行深 ...

  4. 每天一个linux命令目录

    出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html 开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每 ...

  5. 每天一个 Linux 命令(20):find命令之exec

    find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了. exec解释: -exec  参数后面跟的是command ...

  6. 每天一个linux命令(20):find命令之exec

    find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了. exec解释: -exec  参数后面跟的是command ...

  7. 每天一个Linux命令

    每天一个Linux命令(1):ls命令 每天一个Linux命令(2):cd命令 每天一个Linux命令(3):pwd命令 每天一个 Linux 命令(4):mkdir 每天一个 Linux 命令(5) ...

  8. 每天一个linux命令-转载

    每天一个linux命令目录 转载自: http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html   开始详细系统的学习linux常用命令 ...

  9. [转]每天一个linux命令目录

    [转]每天一个linux命令目录 http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html 开始详细系统的学习linux常用命令,坚持每 ...

  10. 每天一个linux命令(45)--telnet命令

    每天一个Linux命令,今天是网络命令中的Telnet. Telnet 命令通常用来远程登录,Telnet 程序是基于 Telnet 协议的远程登录客户端程序.Telnet 协议是TCP/IP协议族中 ...

随机推荐

  1. thinkphp模版主题使用方法

    3.1.3模版主题使用方法,手册貌似没有.配置项: 'DEFAULT_THEME'=>'default',//默认主题 'THEME_LIST'=>'default,theme',//主题 ...

  2. C++ STL nth_element

    #include <iostream>#include <algorithm>#include <deque> using namespace std; int m ...

  3. nginx 解决session一致性

    session 粘滞性每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题. upstream backserver {ip_hash;server ...

  4. IDEA在引入Maven项目后Dependencies中在出现红色波浪线

    解决方法: 移除pom.xml中相关依赖,再重新添加即可. 情况及具体解决方法如下: 1.在Maven Project中 Dependencies 出现红色波浪线,如图所示 2.查询本地仓库:jar包 ...

  5. Python 零基础知识学习

      在开始学习Python之前,首先进入python shell ,输入:import this 命令,如下图所示: Python是一个高层次的结合了解释性.编译性.互动性和面向对象的脚本语言. Py ...

  6. 【SQL】在数据库中发起http请求的小改进

    市面上常见的是用MSXML2.ServerXMLHTTP这个类,但这个类在发起异步请求时并不可靠,就是当send后并不一定会发出这个请求.这里推荐改用Microsoft.XMLHTTP,如果只是简单的 ...

  7. PHP实现发送模板消息(微信公众号版)

    以下为开发步骤: 1.微信公众号为服务号且开通微信认证(其他类型账号不能发送) 2.ip白名单设置你的服务器ip(用于获取access_token) 3.网页授权你的域名(用于获取用户的openid) ...

  8. 解决升Win10系统后VMware虚拟机不能联网的问题

    刚升级到Win10系统,打开虚拟机发现不能联网,其实是系统服务项里缺少两个用到的服务,不能联网了,下面教大家解决联网问题. 1.打开VMware虚拟机主页,点击“编辑——虚拟网络编辑器”. 2.点击左 ...

  9. power bi可视化--乘用车案例

  10. 【计算机视觉】双目测距(六)--三维重建及UI显示

    原文: http://blog.csdn.NET/chenyusiyuan/article/details/5970799 在获取到视差数据后,利用 OpenCV 的 reProjectImageTo ...