首頁 >運維 >linux運維 >Linux中chage指令的語法是什麼

Linux中chage指令的語法是什麼

WBOY
WBOY轉載
2023-05-15 17:25:121475瀏覽

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

指令參數:

##-l列出使用者以及密碼的有效期限#-m密碼可以更改的最小天數。為零代表任何時候都可以更改密碼。 -m#密碼保持有效的最大天數。 -w#密碼過期前,提前收到警告訊息的天數。 使用範例:
##參數

描敘

#-d

指定密碼最後修改日期

-e

#密碼到期的日期,過了這天,此帳號將不可用。 0表示馬上過期,-1表示永不過期。

-h

#顯示幫助資訊並退出

-i

密碼過期後,鎖定帳號的天數

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, --warnday warn_day --warn expdayw, --warn 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 : -1111 #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 day#mins between password change : 7
maximum number of days between password change : 60
number of days of warning before password expires : 7
[#@db-server ~]
#clip_image0011 ##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 befire

#下面要介紹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指令的語法是什麼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除