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:密碼過期前,開始警告天數

? 版權聲明
THE END
喜歡就支持一下吧
點贊5 分享