xref: /freebsd/share/man/man5/passwd.5 (revision 7bd6fde3)
1.\"	$NetBSD: passwd.5,v 1.12.2.2 1999/12/17 23:14:50 he Exp $
2.\"
3.\" Copyright (c) 1988, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\" Portions Copyright (c) 1994, Jason Downs.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     From: @(#)passwd.5	8.1 (Berkeley) 6/5/93
36.\" $FreeBSD$
37.\"
38.Dd February 8, 2005
39.Dt PASSWD 5
40.Os
41.Sh NAME
42.Nm passwd ,
43.Nm master.passwd
44.Nd format of the password file
45.Sh DESCRIPTION
46The
47.Nm
48files are the local source of password information.
49They can be used in conjunction with the Hesiod domains
50.Sq passwd
51and
52.Sq uid ,
53and the
54.Tn NIS
55maps
56.Sq passwd.byname ,
57.Sq passwd.byuid ,
58.Sq master.passwd.byname ,
59and
60.Sq master.passwd.byuid ,
61as controlled by
62.Xr nsswitch.conf 5 .
63.Pp
64For consistency, none of these files should ever be modified
65manually.
66.Pp
67The
68.Nm master.passwd
69file is readable only by root, and consists of newline separated
70records, one per user, containing ten colon (``:'') separated
71fields.
72These fields are as follows:
73.Pp
74.Bl -tag -width password -offset indent
75.It name
76User's login name.
77.It password
78User's
79.Em encrypted
80password.
81.It uid
82User's id.
83.It gid
84User's login group id.
85.It class
86User's login class.
87.It change
88Password change time.
89.It expire
90Account expiration time.
91.It gecos
92General information about the user.
93.It home_dir
94User's home directory.
95.It shell
96User's login shell.
97.El
98.Pp
99The
100.Nm
101file is generated from the
102.Nm master.passwd
103file by
104.Xr pwd_mkdb 8 ,
105has the class, change, and expire fields removed, and the password
106field replaced by a
107.Ql *
108character.
109In the
110.Nm master.passwd
111file, a password of
112.Ql *
113is used to indicate that no one can ever log into that account
114using password authentication (logins through other forms of
115authentication, i.e.\& using
116.Xr ssh 1
117keys, will still work).
118The field only contains encrypted passwords, and
119.Ql *
120can never be the result of encrypting a password.
121.Pp
122The
123.Ar name
124field is the login used to access the computer account, and the
125.Ar uid
126field is the number associated with it.
127They should both be unique
128across the system (and often across a group of systems) since they
129control file access.
130.Pp
131While it is possible to have multiple entries with identical login names
132and/or identical user id's, it is usually a mistake to do so.
133Routines
134that manipulate these files will often return only one of the multiple
135entries, and that one by random selection.
136.Pp
137The login name must never begin with a hyphen (``-''); also, it is strongly
138suggested that neither upper-case characters or dots (``.'') be part
139of the name, as this tends to confuse mailers.
140No field may contain a
141colon (``:'') as this has been used historically to separate the fields
142in the user database.
143.Pp
144The password field is the
145.Em encrypted
146form of the password, see
147.Xr crypt 3 .
148If the
149.Ar password
150field is empty, no password will be required to gain access to the
151machine.
152This is almost invariably a mistake.
153Because these files contain the encrypted user passwords, they should
154not be readable by anyone without appropriate privileges.
155.Pp
156The group field is the group that the user will be placed in upon login.
157Since this system supports multiple groups (see
158.Xr groups 1 )
159this field currently has little special meaning.
160.Pp
161The
162.Ar class
163field is a key for a user's login class.
164Login classes
165are defined in
166.Xr login.conf 5 ,
167which is a
168.Xr termcap 5
169style database of user attributes, accounting, resource,
170and environment settings.
171.Pp
172The
173.Ar change
174field is the number of seconds from the epoch,
175.Dv UTC ,
176until the
177password for the account must be changed.
178This field may be left empty to turn off the password aging feature.
179.Pp
180The
181.Ar expire
182field is the number of seconds from the epoch,
183.Dv UTC ,
184until the
185account expires.
186This field may be left empty to turn off the account aging feature.
187.Pp
188The
189.Ar gecos
190field normally contains comma (``,'') separated subfields as follows:
191.Pp
192.Bl -tag -width office -offset indent -compact
193.It name
194user's full name
195.It office
196user's office number
197.It wphone
198user's work phone number
199.It hphone
200user's home phone number
201.El
202.Pp
203The full name may contain a ampersand (``&'') which will be replaced by
204the capitalized login name when the gecos field is displayed or used
205by various programs such as
206.Xr finger 1 ,
207.Xr sendmail 8 ,
208etc.
209.Pp
210The office and phone number subfields are used by the
211.Xr finger 1
212program, and possibly other applications.
213.Pp
214The user's home directory is the full
215.Ux
216path name where the user
217will be placed on login.
218.Pp
219The shell field is the command interpreter the user prefers.
220If there is nothing in the
221.Ar shell
222field, the Bourne shell
223.Pq Pa /bin/sh
224is assumed.
225.Sh HESIOD SUPPORT
226If
227.Sq dns
228is specified for the
229.Sq passwd
230database in
231.Xr nsswitch.conf 5 ,
232then
233.Nm
234lookups occur from the
235.Sq passwd
236Hesiod domain.
237.Sh NIS SUPPORT
238If
239.Sq nis
240is specified for the
241.Sq passwd
242database in
243.Xr nsswitch.conf 5 ,
244then
245.Nm
246lookups occur from the
247.Sq passwd.byname ,
248.Sq passwd.byuid ,
249.Sq master.passwd.byname ,
250and
251.Sq master.passwd.byuid
252.Tn NIS
253maps.
254.Sh COMPAT SUPPORT
255If
256.Sq compat
257is specified for the
258.Sq passwd
259database, and either
260.Sq dns
261or
262.Sq nis
263is specified for the
264.Sq passwd_compat
265database in
266.Xr nsswitch.conf 5 ,
267then the
268.Nm
269file also supports standard
270.Sq +/-
271exclusions and inclusions, based on user names and netgroups.
272.Pp
273Lines beginning with a ``-'' (minus sign) are entries marked as being excluded
274from any following inclusions, which are marked with a ``+'' (plus sign).
275.Pp
276If the second character of the line is a ``@'' (at sign), the operation
277involves the user fields of all entries in the netgroup specified by the
278remaining characters of the
279.Ar name
280field.
281Otherwise, the remainder of the
282.Ar name
283field is assumed to be a specific user name.
284.Pp
285The ``+'' token may also be alone in the
286.Ar name
287field, which causes all users from either the Hesiod domain
288.Nm
289(with
290.Sq passwd_compat: dns )
291or
292.Sq passwd.byname
293and
294.Sq passwd.byuid
295.Tn NIS
296maps (with
297.Sq passwd_compat: nis )
298to be included.
299.Pp
300If the entry contains non-empty
301.Ar uid
302or
303.Ar gid
304fields, the specified numbers will override the information retrieved
305from the Hesiod domain or the
306.Tn NIS
307maps.
308As well, if the
309.Ar gecos ,
310.Ar dir
311or
312.Ar shell
313entries contain text, it will override the information included via
314Hesiod or
315.Tn NIS .
316On some systems, the
317.Ar passwd
318field may also be overridden.
319.Sh FILES
320.Bl -tag -width ".Pa /etc/master.passwd" -compact
321.It Pa /etc/passwd
322.Tn ASCII
323password file, with passwords removed
324.It Pa /etc/pwd.db
325.Xr db 3 Ns -format
326password database, with passwords removed
327.It Pa /etc/master.passwd
328.Tn ASCII
329password file, with passwords intact
330.It Pa /etc/spwd.db
331.Xr db 3 Ns -format
332password database, with passwords intact
333.El
334.Sh COMPATIBILITY
335The password file format has changed since
336.Bx 4.3 .
337The following awk script can be used to convert your old-style password
338file into a new style password file.
339The additional fields
340.Dq class ,
341.Dq change
342and
343.Dq expire
344are added, but are turned off by default.
345Class is currently not implemented, but change and expire are; to set them,
346use the current day in seconds from the epoch + whatever number of seconds
347of offset you want.
348.Bd -literal -offset indent
349BEGIN { FS = ":"}
350{ print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 }
351.Ed
352.Sh SEE ALSO
353.Xr chpass 1 ,
354.Xr login 1 ,
355.Xr passwd 1 ,
356.Xr crypt 3 ,
357.Xr getpwent 3 ,
358.Xr login.conf 5 ,
359.Xr netgroup 5 ,
360.Xr adduser 8 ,
361.Xr pw 8 ,
362.Xr pwd_mkdb 8 ,
363.Xr vipw 8 ,
364.Xr yp 8
365.Pp
366.%T "Managing NFS and NIS"
367(O'Reilly & Associates)
368.Sh HISTORY
369A
370.Nm
371file format appeared in
372.At v6 .
373.Pp
374The
375.Tn NIS
376.Nm
377file format first appeared in SunOS.
378.Pp
379The Hesiod support first appeared in
380.Fx 4.1 .
381It was imported from the
382.Nx
383Project, where it first appeared in
384.Nx 1.4 .
385.Sh BUGS
386User information should (and eventually will) be stored elsewhere.
387.Pp
388Placing
389.Sq compat
390exclusions in the file after any inclusions will have
391unexpected results.
392