The information database for the username is stored in a simple text file named /etc/passwd. This file is formatted as a number of different colon-separated fields. A small example is shown:
root:bbCsSRB7BZfM.:0:0:root:/root:/bin/sh bin:*:1:1:bin:/bin: daemon:*:2:2:daemon:/sbin: adm:*:3:4:adm:/var/adm: lp:*:4:7:lp:/var/spool/lpd: mail:*:8:12:mail:/var/spool/mail: news:*:9:13:news:/var/lib/news: uucp:*:10:14:uucp:/var/spool/uucppublic: man:*:13:15:man:/usr/man: postmaster:*:14:12:postmaster:/var/spool/mail:/bin/sh www:*:99:103:web server:/etc/httpd:/bin/sh nobody:*:-1:100:nobody:/dev/null: ftp:*:404:1::/home/ftp:/bin/sh jan:/WzbqfJwMa/pA:503:100:Jan Hassebroek:/home/jhassebr:/bin/ksh postgres:gXQrO/hNwy5IQ:506:102:Postgres SQL:/usr/local/postgres:/bin/sh student1:6YNV6cIZxiM2E:507:104:Student 01:/home/student1:/bin/ksh $
Table 12.3 describes the fields, using user jhassebr as an example.
Notice that field 5 contains the user's full name.
Note
UNIX systems today also implement shadow password files. These are readable and writable only to the super user. This improves system security by keeping the encrypted passwords hidden.
If a shadow password file is being used, a single asterisk (*) or x replaces the password in the traditional /etc/passwd file.
The Comment field is also known as the GECOS field, presumably due to influence from the Honeywell GECOS operating system in times past. This field can be subdivided into comma-delimited subfields, as described in Table 12.4.
Field | Example | Description |
---|---|---|
1 | Jan Hassebroek | User's full name |
2 | 3rd Floor | Office location |
3 | x5823 | Office telephone or extension number |
4 | 905-555-1212 | Home telephone number |
In the /etc/passwd file, this would appear as
…:Jan Hassebroek,3rd Floor,x5823,905-555-1212:…
These extra subfields are optional. Comment subfields supply extra information to facilities like the finger(1) command does.
The Comment field also supports the use of the ampersand (&) as a substitution character. When this appears, the username from field 1 is substituted and the first letter is capitalized. The Comment field could take advantage of this feature as follows:
…:& Hassebroek,3rd Floor,x5823,905-555-1212:…
Here, the username jan is substituted for the ampersand character, and the j is capitalized. After the substitution is complete, the first subfield would indicate the name is Jan Hassebroek.
52.14.224.197