Account (/ etc / passwd, / etc / shadow) and the group (/ etc / group, / etc / gshadow) file parsing

1. Account information file

Account information is stored in / etc / passwd file, the command cat / etc / passwd to view the document reads as follows:

[root@192 ~]# 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

An intermediate portion thereof is omitted ...... ......

postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false

Colon-delimited file, first as account name, password as the second placeholder (x denotes the account requires a password before they can log in, is empty, the account without a password to log in), as the third account UID, fourth as GID, as the fifth basic account additional information, general storage account full name, contact information, account home directory location as the sixth, seventh as account login Shell, / bin / bash as can log Shell, / sbin / nologin represent account can not log into the system.

2. Account password file

Account password information is stored in / etc / shadow file, the command cat / etc / shadow view the file as follows:

[root@192 ~]# cat /etc/shadow
root:$6$GmklrLt5M4lqMzDM$KzCJR8T.Bk2Yov4CC20JTaxqb2WQ8A6/dsrgSXb2mKg.rpO1goxVZsk3msqiiuMFAXTrR20tOk.VXDe9KtlLV.::0:99999:7:::
bin:*:17632:0:99999:7:::
daemon:*:17632:0:99999:7:::
adm:*:17632:0:99999:7:::

An intermediate portion thereof is omitted ...... ......

postfix:!!:18141::::::
chrony:!!:18141::::::
tss:!!:18152::::::
mysql:!!:18170::::::

Colon-delimited file, the first as the account name, password and the second column (when not set a password for the account !!, after setting the password encryption display, CentOS6 default algorithm using SHA-512), as the last third there's time to change the password from January 1, 1970 the number of days (so projections last modified date of the password), the fourth as the minimum number of days a password (password to use at least a few days, 0 means unlimited), fifth column the longest number of days a password (default 99999 can be understood as never expire), the sixth listed as the number of days before the warning expired (7 days in advance warning before it expires by default, but after entering the warning date can still use the old password to log system), the first seven as the number of grace days after the password expires (after the password expires, the account set aside a few days to change the password at this time has been unable to use the old password to log system), the eighth as the account expiration date (from January 1, 1970 onwards failure account the number of days), ninth column being reserved for future use.

3. group account information files

Group account information is stored in the / etc / group file, the command cat / etc / group to view the document reads as follows:

[root@192 ~]# cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:

An intermediate portion thereof is omitted ...... ......

postdrop:x:90:
postfix:x:89:
chrony:x:996:
tss:x:59:
mysql:x:27:

Colon-delimited file, the first group as the account name, password placeholder second column, third column the GID, as a fourth group membership information (note here show only basic members, the additional members does not show ).

4. group account password file

Group account password information is stored in the / etc / gshadow file, the command cat / etc / gshadow view the content as follows:

[root@192 ~]# cat /etc/gshadow
root:::
bin:::
daemon:::
sys:::
adm:::
tty:::
disk:::

……中间部分省略……

postdrop:!::
postfix:!::
chrony:!::
tss:!::
mysql:!::

文件以冒号为分隔符,第一列为组账号名称,第二列为组密码(一般为组管理员密码),第三列为组管理员,第四列为组成员(与/etc/group第四列相同)。

 

通过<gpasswd 组名>的方式可以为组设置密码,通过<gpasswd -A 账户名称 组账户名称>可以为组添加管理员。

gpasswd admin      # 设置组密码

gpasswd -A mail admin     # 将mail账户设置为组admin的管理员

 

Guess you like

Origin www.cnblogs.com/opsprobe/p/11618517.html