Linux中chage命令的语法是什么

发布时间:2022-10-14 17:09:52 作者:iii
来源:亿速云 阅读:116

本文小编为大家详细介绍“Linux中chage命令的语法是什么”,内容详细,步骤清晰,细节处理妥当,希望这篇“Linux中chage命令的语法是什么”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

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

命令参数:

参数

描叙

-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 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中chage命令的语法是什么”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. Redis键命令的基本语法是什么
  2. linux中touch命令是什么

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux chage

上一篇:mkdir函数在Linux中与Windows中的区别是什么

下一篇:Linux下如何修改mysql密码

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》