欢迎来到IDC91站长网!
解决服务器各种技术问题,加微信uecomzsr

Linux

当前位置: IDC91 > 服务器教程 > Linux

Linux chage命令详解

时间:2022-05-27 00:13:31|栏目:Linux|点击:

linux chage命令简介:

chage命令用于密码实效管理,该是用来修改帐号和密码的有效期限。它可以修改账号和密码的有效期。对于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

命令参数:

使用示例:

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 26, 2015
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : -1
Maximum number of days between password change : -1
Number of days of warning before password expires : -1
[root@DB-Server ~]#

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

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

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 0 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 : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

下面给大家介绍linux chage命令

功能:修改帐号和密码的有效期限

用法:chage[-l][-m mindays][-M maxdays][-I inactive][-E expiredate][-W warndays][-d lastdays]username

参数:

-l:列出用户的以及密码的有效期限
-m:修改密码的最小天数
-M:修改密码的最大天数
-I:密码过期后,锁定帐号的天数
-d:指定密码最后修改的日期
-E:有效期,0表示立即过期,-1表示永不过期
-W:密码过期前,开始警告天数

上一篇:浅谈Linux内核创建新进程的全过程

栏    目:Linux

下一篇:Linux下Redis的安装和部署

本文标题:Linux chage命令详解

本文地址:https://idc91.com/fuwuqizl/2496.html

广告投放 | 联系我们 | 免责申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

Copyright © 2023 IDC91.COM 版权所有晋ICP备17006296号