liunx之管理本地使用者和組
阿新 • • 發佈:2020-12-26
練習題一
確保新建使用者具有必須30天更改一次密碼
[[email protected] ~]# vim /etc/login.defs
應
該
為
M
A
X
=
30
\color{#FF3030}{應該為MAX=30}
應該為MAX=30
練習題二
建立新組consultants,GID設為35000
[[email protected] ~]# groupadd -g 35000 consultants
[[email protected] ~]# tail -1 /etc/group
consultants:x:35000:
練習題三
為consultants的所有成員配置管理許可權,使其能夠以任何使用者身份執行任何命令
[[email protected] ~]# vim /etc/sudoers
練習題四
建立consultants1、consultants2、consultants3使用者,並使consultants作為他們的補充組
[[email protected] ~]# useradd -G consultants consultants1
[[email protected] ~]# useradd -G consultants consultants2
[[email protected] ~]# useradd -G consultants consultants3
[[email protected] ~]# grep -w consultants /etc/group
consultants:x:35000:consultants1,consultants2,consultants3
練習題五
將consultants1、consultants2、consultants賬戶設為從當天起90天過期
[[email protected] ~]# chage -M 90 consultants1
[[email protected] ~]# chage -M 90 consultants2
[[email protected] ~]# chage -M 90 consultants3
[[email protected] ~]# chage -l consultants3
Last password change : Dec 23, 2020
Password expires : Mar 23, 2021
Password inactive : never
Account expires : never
Minimum number of days between password change : 30
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
正 確 為 : \color{#FF3030}{正確為:} 正確為:
#chage -E $(date -d "+90 days" +%F) consultants1
練習題六
更改consultants2賬戶的密碼策略,使其每15天要求建立新密碼
[[email protected] ~]# chage -m 15 consultants2
[[email protected] ~]# chage -l consultants2
Last password change : Dec 23, 2020
Password expires : Mar 23, 2021
Password inactive : never
Account expires : never
Minimum number of days between password change : 15
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
應 該 為 M A X = 15 \color{#FF3030}{應該為MAX=15} 應該為MAX=15
練習題七
另外,強制consultants1、consultants2、consultants3使用者在第一次登入時更改密碼
[[email protected] ~]# chage -d 0 consultants1
[[email protected] ~]# chage -d 0 consultants2
[[email protected] ~]# chage -d 0 consultants3
[[email protected] ~]# chage -l consultants1
Last password change : password must be changed
Password expires : password must be changed
Password inactive : password must be changed
Account expires : never
Minimum number of days between password change : 30
Maximum number of days between password change : 90
Number of days of warning before password expires : 7