使用命令chage加參數(shù)可以查看,更改用戶密碼的有效期。
1.查看用戶密碼有效期:
chage -l username
如下是永不會(huì)過期的類型
以下是90天有效期的類型?
???????
?2.修改密碼到期時(shí)間
通過參數(shù) -M 設(shè)置賬戶密碼的到期時(shí)間
語法: chage? -M? number-of-days? username
(擴(kuò)展:
-M? 指定的是密碼有效的最大天數(shù)
-m? 指定的是密碼有效的最小天數(shù)。不建議用-m, 使用 默認(rèn) 最小天數(shù)0 即可
)
chage -M 90 user1
密碼過期前幾天(具體幾天視設(shè)置而定)會(huì)有消息提醒
密碼過期前的消息提醒信息類似如下:
Warning: your password will expire in 6 days
密碼過期時(shí),會(huì)強(qiáng)制用戶修改密碼。提示如下:
You are required to change your password immediately (password aged)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for dhinesh
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
?賬號(hào)過期時(shí)間設(shè)置
上面是對用戶的密碼過期時(shí)間設(shè)置,那怎么設(shè)置賬號(hào)的過期時(shí)間。強(qiáng)烈建議不要對root用戶使用?。?!
可以使用 -E 選項(xiàng)設(shè)置賬號(hào)的過期時(shí)間,時(shí)間格式為 "YYYY-MM-DD"以普通賬戶 進(jìn)行舉例:
chage -E "2023-05-21" user1
設(shè)置用戶賬號(hào)不過期文章來源:http://www.zghlxwxcb.cn/news/detail-459891.html
chage ?-E -1 user1
設(shè)置用戶賬號(hào)和密碼永不過期?文章來源地址http://www.zghlxwxcb.cn/news/detail-459891.html
chage -m 0 -M 99999 -E -1 user1
到了這里,關(guān)于Linux設(shè)置用戶的密碼有效期的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!