用户配置文件
[root@evan-01 ~]# ls /etc/passwd
/etc/passwd
[root@evan-01 ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:997:User for polkitd:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
evan1:x:1000:1000::/home/evan1:/bin/bash
evan2:x:1001:1001::/home/evan2:/bin/bash
[root@evan-01 ~]#
上面那么多的用户,都是系统自带的,从uid 1000位往后是我们自己创建的
evan1:x:1000:1000::/home/evan1:/bin/bash
evan2:x:1001:1001::/home/evan2:/bin/bash
用户名 | 密码 | uid | gid | 用户注释信息 | 用户家目录 | 用户的shell |
---|---|---|---|---|---|---|
evan1 | x | 1000 | 1000 | 空 | /home/evan1 | /bin/bash |
evan2 | x | 1001 | 1001 | 空 | /home/evan2 | /bin/bash |
密码配置文件
[root@evan-01 ~]# ls /etc/shadow
/etc/shadow
[root@evan-01 ~]# cat /etc/shadow
root:$6$zrR2hsrbue9Do/2U$qv8De2HHKnhS0uJ98fAh2z/uFYYIHsYyxLcMosBEd3Cuzl3nrClgu9LogBIBJa1dK/5BydYLgWneNahiO/FJY1::0:99999:7:::
bin:*:17110:0:99999:7:::
daemon:*:17110:0:99999:7:::
adm:*:17110:0:99999:7:::
lp:*:17110:0:99999:7:::
sync:*:17110:0:99999:7:::
shutdown:*:17110:0:99999:7:::
halt:*:17110:0:99999:7:::
mail:*:17110:0:99999:7:::
operator:*:17110:0:99999:7:::
games:*:17110:0:99999:7:::
ftp:*:17110:0:99999:7:::
nobody:*:17110:0:99999:7:::
systemd-network:!!:18116::::::
dbus:!!:18116::::::
polkitd:!!:18116::::::
postfix:!!:18116::::::
sshd:!!:18116::::::
chrony:!!:18116::::::
evan1:!!:18117:0:99999:7:::
evan2:!!:18117:0:99999:7:::
[root@evan-01 ~]#
这个文件和用户配置文件一 一对应的(可以往上翻下用户配置文件/etc/passwd看下),专门控制用户密码的
只有root用户我们设置了密码,密码是加密的,不能反编译
root:$6$zrR2hsrbue9Do/2U$qv8De2HHKnhS0uJ98fAh2z/uFYYIHsYyxLcMosBEd3Cuzl3nrClgu9LogBIBJa1dK/5BydYLgWneNahiO/FJY1::0:99999:7:::
给evan1用户设置个密码,密码设置成和root相同的
[root@evan-01 ~]# passwd evan1
Changing password for user evan1.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@evan-01 ~]#
一行里面执行2个命令,查看下密码
[root@evan-01 ~]# head -n1 /etc/shadow;tail -n2 /etc/shadow
root:$6$zrR2hsrbue9Do/2U$qv8De2HHKnhS0uJ98fAh2z/uFYYIHsYyxLcMosBEd3Cuzl3nrClgu9LogBIBJa1dK/5BydYLgWneNahiO/FJY1::0:99999:7:::
evan1:$6$sZaQ18JJ$a3fX2DGLV/ag4CJAdhb/zbJFqQTR6cAW/Grs7HwdkE6mDit8CRW4uw43LiWDWjn/JSsfYGqUcJSY6ul9ruUgX0:18121:0:99999:7:::
evan2:!!:18117:0:99999:7:::
[root@evan-01 ~]#
两个密码的明文是一模一样的,但是加密后的字符是不一样的
查看下这7段都是什么意思
每个字段的含义是:
[root@evan-01 ~]# man shadow
...(省略一些内容)
The meanings of each field are:
· sp_namp - pointer to null-terminated user name
· sp_pwdp - pointer to null-terminated password
· sp_lstchg - days since Jan 1, 1970 password was last changed
· sp_min - days before which password may not be changed
· sp_max - days after which password must be changed
· sp_warn - days before password is to expire that user is warned of pending password expiration
· sp_inact - days after password expires that account is considered inactive and disabled
· sp_expire - days since Jan 1, 1970 when account will be disabled
· sp_flag - reserved for future us
1、用户名
2、密码
3、最近更改密码的日期
4、要过多少天才可以更改密码
5、密码多少天都到期,在多少天内必须要更改密码
6、密码到期前的提醒
7、账号的失效期限(账号过期后,再过几天失效)
8、账号的生命周期(距离1970年1月1日有多少天,在这个日期前可以使用)
9、保留字段,没有实际含义