![有人能解释一下 getent passwd 命令的输出吗?](https://linux22.com/image/1132758/%E6%9C%89%E4%BA%BA%E8%83%BD%E8%A7%A3%E9%87%8A%E4%B8%80%E4%B8%8B%20getent%20passwd%20%E5%91%BD%E4%BB%A4%E7%9A%84%E8%BE%93%E5%87%BA%E5%90%97%EF%BC%9F.png)
mymac
这是我在 juggernaut machine 上的个人用户帐户
mymac:x:1000:1000:juggernaut,,,:/home/mymac:/bin/bash
x, 1000 , 1000 是什么意思?后面的逗号又是什么意思?
类似地,也解释一下:
root:x:0:0:root:/root:/bin/bash
答案1
/etc/passwd contains one line for each user account, with seven fields
delimited by colons (“:”). These fields are:
· login name
· optional encrypted password
· numerical user ID
· numerical group ID
· user name or comment field
· user home directory
· optional user command interpreter
这x
将是可选的加密密码,手册页进一步说道:
The encrypted password field may be blank, in which case no password is
required to authenticate as the specified login name. However, some
applications which read the /etc/passwd file may decide not to permit
any access at all if the password field is blank. If the password field
is a lower-case “x”, then the encrypted password is actually stored in
the shadow(5) file instead; there must be a corresponding line in the
/etc/shadow file, or else the user account is invalid. If the password
field is any other string, then it will be treated as an encrypted
password, as specified by crypt(3).
逗号分隔GECOS 字段:
GECOS 字段的典型格式是以逗号分隔的列表,其顺序如下:
- 用户的全名(或应用程序名称,如果该帐户用于程序)
- 楼宇及房间号码或联系人
- 办公室电话号码
- 任何其他联系信息(寻呼机号码、传真等)
所以:
mymac:x:1000:1000:juggernaut,,,:/home/mymac:/bin/bash
| | | | | | |
| | | | | | Login shell
| | | | | Home directory
| | | | GECOS fields (full name, etc.)
| | | Primary Group id
| | User ID
| Encrypted password indicator
Username