xref: /freebsd/usr.sbin/pw/pw.8 (revision 87d6b5caf6ad8fb8de5a783afcea897c029100a1)
1db34a710SJoerg Wunsch.\" Copyright (C) 1996
2db34a710SJoerg Wunsch.\" David L. Nugent.  All rights reserved.
3d6f907dcSJoerg Wunsch.\"
49fd0dafcSJoerg Wunsch.\" Redistribution and use in source and binary forms, with or without
59fd0dafcSJoerg Wunsch.\" modification, are permitted provided that the following conditions
69fd0dafcSJoerg Wunsch.\" are met:
79fd0dafcSJoerg Wunsch.\" 1. Redistributions of source code must retain the above copyright
89fd0dafcSJoerg Wunsch.\"    notice, this list of conditions and the following disclaimer.
99fd0dafcSJoerg Wunsch.\" 2. Redistributions in binary form must reproduce the above copyright
109fd0dafcSJoerg Wunsch.\"    notice, this list of conditions and the following disclaimer in the
119fd0dafcSJoerg Wunsch.\"    documentation and/or other materials provided with the distribution.
12d6f907dcSJoerg Wunsch.\"
13db34a710SJoerg Wunsch.\" THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND
149fd0dafcSJoerg Wunsch.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
159fd0dafcSJoerg Wunsch.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16db34a710SJoerg Wunsch.\" ARE DISCLAIMED.  IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
179fd0dafcSJoerg Wunsch.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
189fd0dafcSJoerg Wunsch.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199fd0dafcSJoerg Wunsch.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
209fd0dafcSJoerg Wunsch.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
219fd0dafcSJoerg Wunsch.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
229fd0dafcSJoerg Wunsch.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
239fd0dafcSJoerg Wunsch.\" SUCH DAMAGE.
249fd0dafcSJoerg Wunsch.\"
2597d92980SPeter Wemm.\" $FreeBSD$
269fd0dafcSJoerg Wunsch.\"
2787d6b5caSIan Dowse.Dd January 11, 2004
28d6f907dcSJoerg Wunsch.Dt PW 8
29d6f907dcSJoerg Wunsch.Os
30d6f907dcSJoerg Wunsch.Sh NAME
31d6f907dcSJoerg Wunsch.Nm pw
329fd0dafcSJoerg Wunsch.Nd create, remove, modify & display system users and groups
33d6f907dcSJoerg Wunsch.Sh SYNOPSIS
34e97407b4SRuslan Ermilov.Nm
355f12594aSDavid Nugent.Op Fl V Ar etcdir
36d6f907dcSJoerg Wunsch.Ar useradd
37d6f907dcSJoerg Wunsch.Op name|uid
38d6f907dcSJoerg Wunsch.Op Fl C Ar config
39d6f907dcSJoerg Wunsch.Op Fl q
40d6f907dcSJoerg Wunsch.Op Fl n Ar name
41d6f907dcSJoerg Wunsch.Op Fl u Ar uid
42d6f907dcSJoerg Wunsch.Op Fl c Ar comment
43d6f907dcSJoerg Wunsch.Op Fl d Ar dir
44d6f907dcSJoerg Wunsch.Op Fl e Ar date
45d6f907dcSJoerg Wunsch.Op Fl p Ar date
46d6f907dcSJoerg Wunsch.Op Fl g Ar group
47d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
48d6f907dcSJoerg Wunsch.Op Fl m
49d6f907dcSJoerg Wunsch.Op Fl k Ar dir
50f5875822SSADA Kenji.Op Fl w Ar method
51d6f907dcSJoerg Wunsch.Op Fl s Ar shell
52d6f907dcSJoerg Wunsch.Op Fl o
53d6f907dcSJoerg Wunsch.Op Fl L Ar class
5487d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd
559fd0dafcSJoerg Wunsch.Op Fl N
569fd0dafcSJoerg Wunsch.Op Fl P
57f1d684faSDavid Nugent.Op Fl Y
58e97407b4SRuslan Ermilov.Nm
595f12594aSDavid Nugent.Op Fl V Ar etcdir
60d6f907dcSJoerg Wunsch.Ar useradd
61d6f907dcSJoerg Wunsch.Op name|uid
62f1d684faSDavid Nugent.Fl D
63d6f907dcSJoerg Wunsch.Op Fl C Ar config
64d6f907dcSJoerg Wunsch.Op Fl q
65d6f907dcSJoerg Wunsch.Op Fl b Ar dir
66d6f907dcSJoerg Wunsch.Op Fl e Ar days
67d6f907dcSJoerg Wunsch.Op Fl p Ar days
68d6f907dcSJoerg Wunsch.Op Fl g Ar group
69d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
70d6f907dcSJoerg Wunsch.Op Fl k Ar dir
71610a5778SRuslan Ermilov.Op Fl u Ar min , Ns Ar max
72610a5778SRuslan Ermilov.Op Fl i Ar min , Ns Ar max
73d6f907dcSJoerg Wunsch.Op Fl w Ar method
74d6f907dcSJoerg Wunsch.Op Fl s Ar shell
75f1d684faSDavid Nugent.Op Fl y Ar path
76e97407b4SRuslan Ermilov.Nm
775f12594aSDavid Nugent.Op Fl V Ar etcdir
78d6f907dcSJoerg Wunsch.Ar userdel
79d6f907dcSJoerg Wunsch.Op name|uid
80d6f907dcSJoerg Wunsch.Op Fl n Ar name
81d6f907dcSJoerg Wunsch.Op Fl u Ar uid
82d6f907dcSJoerg Wunsch.Op Fl r
83f1d684faSDavid Nugent.Op Fl Y
84e97407b4SRuslan Ermilov.Nm
855f12594aSDavid Nugent.Op Fl V Ar etcdir
86d6f907dcSJoerg Wunsch.Ar usermod
87d6f907dcSJoerg Wunsch.Op name|uid
88d6f907dcSJoerg Wunsch.Op Fl C Ar config
89d6f907dcSJoerg Wunsch.Op Fl q
90d6f907dcSJoerg Wunsch.Op Fl n Ar name
91d6f907dcSJoerg Wunsch.Op Fl u Ar uid
92d6f907dcSJoerg Wunsch.Op Fl c Ar comment
93d6f907dcSJoerg Wunsch.Op Fl d Ar dir
94d6f907dcSJoerg Wunsch.Op Fl e Ar date
95d6f907dcSJoerg Wunsch.Op Fl p Ar date
96d6f907dcSJoerg Wunsch.Op Fl g Ar group
97d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
98d6f907dcSJoerg Wunsch.Op Fl l Ar name
99d6f907dcSJoerg Wunsch.Op Fl m
100d6f907dcSJoerg Wunsch.Op Fl k Ar dir
1019fd0dafcSJoerg Wunsch.Op Fl w Ar method
102d6f907dcSJoerg Wunsch.Op Fl s Ar shell
103d6f907dcSJoerg Wunsch.Op Fl L Ar class
10487d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd
1059fd0dafcSJoerg Wunsch.Op Fl N
1069fd0dafcSJoerg Wunsch.Op Fl P
107f1d684faSDavid Nugent.Op Fl Y
108e97407b4SRuslan Ermilov.Nm
1095f12594aSDavid Nugent.Op Fl V Ar etcdir
110d6f907dcSJoerg Wunsch.Ar usershow
111d6f907dcSJoerg Wunsch.Op name|uid
112d6f907dcSJoerg Wunsch.Op Fl n Ar name
113d6f907dcSJoerg Wunsch.Op Fl u Ar uid
114d6f907dcSJoerg Wunsch.Op Fl F
1159fd0dafcSJoerg Wunsch.Op Fl P
1164731d076SDima Dorfman.Op Fl 7
117d6f907dcSJoerg Wunsch.Op Fl a
118e97407b4SRuslan Ermilov.Nm
1195f12594aSDavid Nugent.Op Fl V Ar etcdir
1209fd0dafcSJoerg Wunsch.Ar usernext
1219fd0dafcSJoerg Wunsch.Op Fl C Ar config
1229fd0dafcSJoerg Wunsch.Op Fl q
123e97407b4SRuslan Ermilov.Nm
1245f12594aSDavid Nugent.Op Fl V Ar etcdir
125d6f907dcSJoerg Wunsch.Ar groupadd
126d6f907dcSJoerg Wunsch.Op group|gid
127d6f907dcSJoerg Wunsch.Op Fl C Ar config
128d6f907dcSJoerg Wunsch.Op Fl q
129d6f907dcSJoerg Wunsch.Op Fl n Ar group
130d6f907dcSJoerg Wunsch.Op Fl g Ar gid
1319fd0dafcSJoerg Wunsch.Op Fl M Ar members
132d6f907dcSJoerg Wunsch.Op Fl o
13387d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd
1349fd0dafcSJoerg Wunsch.Op Fl N
1359fd0dafcSJoerg Wunsch.Op Fl P
136f1d684faSDavid Nugent.Op Fl Y
137e97407b4SRuslan Ermilov.Nm
1385f12594aSDavid Nugent.Op Fl V Ar etcdir
139d6f907dcSJoerg Wunsch.Ar groupdel
14006f64964SJoseph Koshy.Op group|gid
141d6f907dcSJoerg Wunsch.Op Fl n Ar name
142d6f907dcSJoerg Wunsch.Op Fl g Ar gid
143f1d684faSDavid Nugent.Op Fl Y
144e97407b4SRuslan Ermilov.Nm
1455f12594aSDavid Nugent.Op Fl V Ar etcdir
146d6f907dcSJoerg Wunsch.Ar groupmod
14706f64964SJoseph Koshy.Op group|gid
148d6f907dcSJoerg Wunsch.Op Fl C Ar config
149d6f907dcSJoerg Wunsch.Op Fl q
150d6f907dcSJoerg Wunsch.Op Fl n Ar name
151d6f907dcSJoerg Wunsch.Op Fl g Ar gid
152d6f907dcSJoerg Wunsch.Op Fl l Ar name
1539fd0dafcSJoerg Wunsch.Op Fl M Ar members
1549fd0dafcSJoerg Wunsch.Op Fl m Ar newmembers
15587d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd
1569fd0dafcSJoerg Wunsch.Op Fl N
1579fd0dafcSJoerg Wunsch.Op Fl P
158f1d684faSDavid Nugent.Op Fl Y
159e97407b4SRuslan Ermilov.Nm
1605f12594aSDavid Nugent.Op Fl V Ar etcdir
161d6f907dcSJoerg Wunsch.Ar groupshow
16206f64964SJoseph Koshy.Op group|gid
163d6f907dcSJoerg Wunsch.Op Fl n Ar name
164d6f907dcSJoerg Wunsch.Op Fl g Ar gid
165d6f907dcSJoerg Wunsch.Op Fl F
1669fd0dafcSJoerg Wunsch.Op Fl P
167d6f907dcSJoerg Wunsch.Op Fl a
168e97407b4SRuslan Ermilov.Nm
1695f12594aSDavid Nugent.Op Fl V Ar etcdir
1709fd0dafcSJoerg Wunsch.Ar groupnext
1719fd0dafcSJoerg Wunsch.Op Fl C Ar config
1729fd0dafcSJoerg Wunsch.Op Fl q
173e468afb4SDima Dorfman.Nm
174e468afb4SDima Dorfman.Op Fl V Ar etcdir
175e468afb4SDima Dorfman.Ar lock
176e468afb4SDima Dorfman.Op name|uid
177e468afb4SDima Dorfman.Op Fl C Ar config
178e468afb4SDima Dorfman.Op Fl q
179e468afb4SDima Dorfman.Nm
180e468afb4SDima Dorfman.Op Fl V Ar etcdir
181e468afb4SDima Dorfman.Ar unlock
182e468afb4SDima Dorfman.Op name|uid
183e468afb4SDima Dorfman.Op Fl C Ar config
184e468afb4SDima Dorfman.Op Fl q
185d6f907dcSJoerg Wunsch.Sh DESCRIPTION
186490d5836SPhilippe CharnierThe
187490d5836SPhilippe Charnier.Nm
188490d5836SPhilippe Charnierutility is a command-line based editor for the system
1891dcc6ec7SPhilippe Charnier.Ar user
190d6f907dcSJoerg Wunschand
1911dcc6ec7SPhilippe Charnier.Ar group
1923a7e7077SDaniel O'Callaghanfiles, allowing the superuser an easy to use and standardized way of adding,
193d6f907dcSJoerg Wunschmodifying and removing users and groups.
194d6f907dcSJoerg WunschNote that
1951dcc6ec7SPhilippe Charnier.Nm
196490d5836SPhilippe Charnieronly operates on the local user and group files.
197490d5836SPhilippe Charnier.Tn NIS
198490d5836SPhilippe Charnierusers and groups must be
199490d5836SPhilippe Charniermaintained on the
200490d5836SPhilippe Charnier.Tn NIS
201490d5836SPhilippe Charnierserver.
202490d5836SPhilippe CharnierThe
203490d5836SPhilippe Charnier.Nm
204490d5836SPhilippe Charnierutility handles updating the
205053375e8SMike Pritchard.Pa passwd ,
206053375e8SMike Pritchard.Pa master.passwd ,
207053375e8SMike Pritchard.Pa group
208053375e8SMike Pritchardand the secure and insecure
209d6f907dcSJoerg Wunschpassword database files, and must be run as root.
210d6f907dcSJoerg Wunsch.Pp
211137db389SSteve PriceThe first one or two keywords provided to
212137db389SSteve Price.Nm
213137db389SSteve Priceon the command line provide the context for the remainder of the arguments.
214137db389SSteve PriceThe keywords
215d6f907dcSJoerg Wunsch.Ar user
216d6f907dcSJoerg Wunschand
217d6f907dcSJoerg Wunsch.Ar group
218137db389SSteve Pricemay be combined with
219d6f907dcSJoerg Wunsch.Ar add ,
220d6f907dcSJoerg Wunsch.Ar del ,
2219fd0dafcSJoerg Wunsch.Ar mod ,
222d6f907dcSJoerg Wunsch.Ar show ,
2239fd0dafcSJoerg Wunschor
224137db389SSteve Price.Ar next
2254e86fcacSSheldon Hearnin any order.
2264e86fcacSSheldon Hearn(For example,
227137db389SSteve Price.Ar showuser ,
228137db389SSteve Price.Ar usershow ,
229610a5778SRuslan Ermilov.Ar show user ,
230610a5778SRuslan Ermilovand
231137db389SSteve Price.Ar user show
232137db389SSteve Priceall mean the same thing.)
233137db389SSteve PriceThis flexibility is useful for interactive scripts calling
2341dcc6ec7SPhilippe Charnier.Nm
235137db389SSteve Pricefor user and group database manipulation.
236d6f907dcSJoerg WunschFollowing these keywords, you may optionally specify the user or group name or numeric
237d6f907dcSJoerg Wunschid as an alternative to using the
238d6f907dcSJoerg Wunsch.Fl n Ar name ,
239d6f907dcSJoerg Wunsch.Fl u Ar uid ,
240d6f907dcSJoerg Wunsch.Fl g Ar gid
2419fd0dafcSJoerg Wunschoptions.
242d6f907dcSJoerg Wunsch.Pp
243d5a3b1edSDima DorfmanThe following flags are common to most or all modes of operation:
244d6f907dcSJoerg Wunsch.Pp
2459fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
2465f12594aSDavid Nugent.It Fl V Ar etcdir
2475f12594aSDavid NugentThis flag sets an alternate location for the password, group and configuration files,
2485f12594aSDavid Nugentand may be used to maintain a user/group database in an alternate location.
2495f12594aSDavid NugentIf this switch is specified, the system
2505f12594aSDavid Nugent.Pa /etc/pw.conf
2515f12594aSDavid Nugentwill not be sourced for default configuration data, but the file pw.conf in the
2525f12594aSDavid Nugentspecified directory will be used instead (or none, if it does not exist).
2535f12594aSDavid NugentThe
2545f12594aSDavid Nugent.Fl C
2555f12594aSDavid Nugentflag may be used to override this behaviour.
2565f12594aSDavid NugentAs an exception to the general rule where options must follow the operation
2575f12594aSDavid Nugenttype, the
2585f12594aSDavid Nugent.Fl V
2595f12594aSDavid Nugentflag may be used on the command line before the operation keyword.
260d6f907dcSJoerg Wunsch.It Fl C Ar config
261d6f907dcSJoerg WunschBy default,
2621dcc6ec7SPhilippe Charnier.Nm
263d6f907dcSJoerg Wunschreads the file
264d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
265137db389SSteve Priceto obtain policy information on how new user accounts and groups are to be created.
266137db389SSteve PriceThe
2679fd0dafcSJoerg Wunsch.Fl C
2689fd0dafcSJoerg Wunschoption specifies a different configuration file.
269137db389SSteve PriceWhile most of the contents of the configuration file may be overridden via
270137db389SSteve Pricecommand-line options, it may be more convenient to keep standard information in a
271137db389SSteve Priceconfiguration file.
272d6f907dcSJoerg Wunsch.It Fl q
273d6f907dcSJoerg WunschUse of this option causes
2741dcc6ec7SPhilippe Charnier.Nm
275d6f907dcSJoerg Wunschto suppress error messages, which may be useful in interactive environments where it
276d6f907dcSJoerg Wunschis preferable to interpret status codes returned by
2771dcc6ec7SPhilippe Charnier.Nm
278d6f907dcSJoerg Wunschrather than messing up a carefully formatted display.
2799fd0dafcSJoerg Wunsch.It Fl N
280137db389SSteve PriceThis option is available in
281137db389SSteve Price.Ar add
282137db389SSteve Priceand
283137db389SSteve Price.Ar modify
284137db389SSteve Priceoperations, and tells
2851dcc6ec7SPhilippe Charnier.Nm
286137db389SSteve Priceto output the result of the operation without updating the user or group
287137db389SSteve Pricedatabases.
2889fd0dafcSJoerg WunschYou may use the
2899fd0dafcSJoerg Wunsch.Fl P
2909fd0dafcSJoerg Wunschoption to switch between standard passwd and readable formats.
291f1d684faSDavid Nugent.It Fl Y
292f1d684faSDavid NugentUsing this option with any of the update modes causes
2931dcc6ec7SPhilippe Charnier.Nm
294f1d684faSDavid Nugentto run
295f1d684faSDavid Nugent.Xr make 1
296f1d684faSDavid Nugentafter changing to the directory
297f1d684faSDavid Nugent.Pa /var/yp .
298490d5836SPhilippe CharnierThis is intended to allow automatic updating of
299490d5836SPhilippe Charnier.Tn NIS
300490d5836SPhilippe Charnierdatabase files.
301490d5836SPhilippe CharnierIf separate passwd and group files are being used by
302490d5836SPhilippe Charnier.Tn NIS ,
303490d5836SPhilippe Charnierthen use the
304f1d684faSDavid Nugent.Fl y Ar path
305490d5836SPhilippe Charnieroption to specify the location of the
306490d5836SPhilippe Charnier.Tn NIS
307490d5836SPhilippe Charnierpasswd database so that
308137db389SSteve Price.Nm
309137db389SSteve Pricewill concurrently update it with the system password
310f1d684faSDavid Nugentdatabases.
311d6f907dcSJoerg Wunsch.El
312d6f907dcSJoerg Wunsch.Sh USER OPTIONS
313d6f907dcSJoerg WunschThe following options apply to the
314137db389SSteve Price.Ar useradd
315d6f907dcSJoerg Wunschand
316137db389SSteve Price.Ar usermod
317d6f907dcSJoerg Wunschcommands:
318d6f907dcSJoerg Wunsch.Pp
3199fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
320d6f907dcSJoerg Wunsch.It Fl n Ar name
3211dcc6ec7SPhilippe CharnierSpecify the user/account name.
322d6f907dcSJoerg Wunsch.It Fl u Ar uid
3231dcc6ec7SPhilippe CharnierSpecify the user/account numeric id.
324d6f907dcSJoerg Wunsch.Pp
325137db389SSteve PriceUsually, you only need to provide one or the other of these options, as the account
326137db389SSteve Pricename will imply the uid, or vice versa.
327137db389SSteve PriceHowever, there are times when you need to provide both.
328d6f907dcSJoerg WunschFor example, when changing the uid of an existing user with
329d6f907dcSJoerg Wunsch.Ar usermod ,
330d6f907dcSJoerg Wunschor overriding the default uid when creating a new account.
331d6f907dcSJoerg WunschIf you wish
3321dcc6ec7SPhilippe Charnier.Nm
333137db389SSteve Priceto automatically allocate the uid to a new user with
334d6f907dcSJoerg Wunsch.Ar useradd ,
335d6f907dcSJoerg Wunschthen you should
336d6f907dcSJoerg Wunsch.Em not
337d6f907dcSJoerg Wunschuse the
33808657612SRuslan Ermilov.Fl u
3399fd0dafcSJoerg Wunschoption.
340137db389SSteve PriceYou may also provide either the account or userid immediately after the
341137db389SSteve Price.Ar useradd ,
342137db389SSteve Price.Ar userdel ,
343137db389SSteve Price.Ar usermod
344137db389SSteve Priceor
345137db389SSteve Price.Ar usershow
346137db389SSteve Pricekeywords on the command line without using the
34708657612SRuslan Ermilov.Fl n
348137db389SSteve Priceor
34908657612SRuslan Ermilov.Fl u
350137db389SSteve Priceoptions.
351d6f907dcSJoerg Wunsch.El
352d6f907dcSJoerg Wunsch.Pp
353d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
354d6f907dcSJoerg Wunsch.It Fl c Ar comment
355d6f907dcSJoerg WunschThis field sets the contents of the passwd GECOS field, which normally contains up
356d6f907dcSJoerg Wunschto four comma-separated fields containing the user's full name, office or location,
357137db389SSteve Priceand work and home phone numbers.
358d6f907dcSJoerg WunschThese sub-fields are used by convention only, however, and are optional.
359d6f907dcSJoerg WunschIf this field is to contain spaces, you need to quote the comment itself with double
360d6f907dcSJoerg Wunschquotes
361d6f907dcSJoerg Wunsch.Ql \&" .
362d6f907dcSJoerg WunschAvoid using commas in this field as these are used as sub-field separators, and the
363d6f907dcSJoerg Wunschcolon
364d6f907dcSJoerg Wunsch.Ql \&:
365137db389SSteve Pricecharacter also cannot be used as this is the field separator for the passwd
366137db389SSteve Pricefile itself.
367d6f907dcSJoerg Wunsch.It Fl d Ar dir
368d6f907dcSJoerg WunschThis option sets the account's home directory.
369d6f907dcSJoerg WunschNormally, you will only use this if the home directory is to be different from the
370137db389SSteve Pricedefault determined from
371137db389SSteve Price.Pa /etc/pw.conf
3721dcc6ec7SPhilippe Charnier- normally
3731dcc6ec7SPhilippe Charnier.Pa /home
374137db389SSteve Pricewith the account name as a subdirectory.
375d6f907dcSJoerg Wunsch.It Fl e Ar date
3761dcc6ec7SPhilippe CharnierSet the account's expiration date.
377d6f907dcSJoerg WunschFormat of the date is either a UNIX time in decimal, or a date in
378137db389SSteve Price.Ql dd-mmm-yy[yy]
379d6f907dcSJoerg Wunschformat, where dd is the day, mmm is the month, either in numeric or alphabetic format
3801dcc6ec7SPhilippe Charnier('Jan', 'Feb', etc) and year is either a two or four digit year.
381d6f907dcSJoerg WunschThis option also accepts a relative date in the form
382d6f907dcSJoerg Wunsch.Ql \&+n[mhdwoy]
383d6f907dcSJoerg Wunschwhere
384d6f907dcSJoerg Wunsch.Ql \&n
385d6f907dcSJoerg Wunschis a decimal, octal (leading 0) or hexadecimal (leading 0x) digit followed by the
386053375e8SMike Pritchardnumber of Minutes, Hours, Days, Weeks, Months or Years from the current date at
387137db389SSteve Pricewhich the expiration date is to be set.
388d6f907dcSJoerg Wunsch.It Fl p Ar date
3891dcc6ec7SPhilippe CharnierSet the account's password expiration date.
390137db389SSteve PriceThis field is similar to the account expiration date option, except that it
391d6f907dcSJoerg Wunschapplies to forced password changes.
392137db389SSteve PriceThis is set in the same manner as the
39308657612SRuslan Ermilov.Fl e
394137db389SSteve Priceoption.
395d6f907dcSJoerg Wunsch.It Fl g Ar group
3961dcc6ec7SPhilippe CharnierSet the account's primary group to the given group.
397d6f907dcSJoerg Wunsch.Ar group
398137db389SSteve Pricemay be defined by either its name or group number.
399d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
400490d5836SPhilippe CharnierSet additional group memberships for an account.
401d6f907dcSJoerg Wunsch.Ar grouplist
402137db389SSteve Priceis a comma-separated list of group names or group numbers.
403137db389SSteve PriceThe user's name is added to the group lists in
404d6f907dcSJoerg Wunsch.Pa /etc/group ,
405137db389SSteve Priceand
406d6f907dcSJoerg Wunschremoved from any groups not specified in
407d6f907dcSJoerg Wunsch.Ar grouplist .
408137db389SSteve PriceNote: a user should not be added to their primary group with
409137db389SSteve Price.Ar grouplist .
410137db389SSteve PriceAlso, group membership changes do not take effect for current user login
411137db389SSteve Pricesessions, requiring the user to reconnect to be affected by the changes.
4129fd0dafcSJoerg Wunsch.It Fl L Ar class
4139fd0dafcSJoerg WunschThis option sets the login class for the user being created.
4149fd0dafcSJoerg WunschSee
4159fd0dafcSJoerg Wunsch.Xr login.conf 5
41616b4ad52SGiorgos Keramidasand
41716b4ad52SGiorgos Keramidas.Xr passwd 5
418137db389SSteve Pricefor more information on user login classes.
419d6f907dcSJoerg Wunsch.It Fl m
420d6f907dcSJoerg WunschThis option instructs
4211dcc6ec7SPhilippe Charnier.Nm
422d6f907dcSJoerg Wunschto attempt to create the user's home directory.
423d6f907dcSJoerg WunschWhile primarily useful when adding a new account with
424d6f907dcSJoerg Wunsch.Ar useradd ,
425d6f907dcSJoerg Wunschthis may also be of use when moving an existing user's home directory elsewhere on
426d6f907dcSJoerg Wunschthe file system.
427d6f907dcSJoerg WunschThe new home directory is populated with the contents of the
428d6f907dcSJoerg Wunsch.Ar skeleton
429d6f907dcSJoerg Wunschdirectory, which typically contains a set of shell configuration files that the
430053375e8SMike Pritcharduser may personalize to taste.
431d6f907dcSJoerg WunschWhen
43208657612SRuslan Ermilov.Fl m
433d6f907dcSJoerg Wunschis used on an account with
434d6f907dcSJoerg Wunsch.Ar usermod ,
435137db389SSteve Priceexisting configuration files in the user's home directory are
436d6f907dcSJoerg Wunsch.Em not
437137db389SSteve Priceoverwritten from the skeleton files.
438d6f907dcSJoerg Wunsch.Pp
439137db389SSteve PriceWhen a user's home directory is created, it will by default be a subdirectory of the
440d6f907dcSJoerg Wunsch.Ar basehome
441137db389SSteve Pricedirectory as specified by the
44208657612SRuslan Ermilov.Fl b
443137db389SSteve Priceoption (see below), bearing the name of the new account.
444137db389SSteve PriceThis can be overridden by the
44508657612SRuslan Ermilov.Fl d
446d6f907dcSJoerg Wunschoption on the command line, if desired.
447d6f907dcSJoerg Wunsch.It Fl k Ar dir
4481dcc6ec7SPhilippe CharnierSet the
449d6f907dcSJoerg Wunsch.Ar skeleton
450137db389SSteve Pricedirectory, from which basic startup and configuration files are copied when
451d6f907dcSJoerg Wunschthe user's home directory is created.
452137db389SSteve PriceThis option only has meaning when used with the
45308657612SRuslan Ermilov.Fl d
454137db389SSteve Priceor
45508657612SRuslan Ermilov.Fl m
456137db389SSteve Priceflags.
457d6f907dcSJoerg Wunsch.It Fl s Ar shell
4581dcc6ec7SPhilippe CharnierSet or changes the user's login shell to
459d6f907dcSJoerg Wunsch.Ar shell .
460d6f907dcSJoerg WunschIf the path to the shell program is omitted,
4611dcc6ec7SPhilippe Charnier.Nm
462d6f907dcSJoerg Wunschsearches the
463d6f907dcSJoerg Wunsch.Ar shellpath
464d6f907dcSJoerg Wunschspecified in
465d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
466d6f907dcSJoerg Wunschand fills it in as appropriate.
467d6f907dcSJoerg WunschNote that unless you have a specific reason to do so, you should avoid
468d6f907dcSJoerg Wunschspecifying the path - this will allow
4691dcc6ec7SPhilippe Charnier.Nm
470d6f907dcSJoerg Wunschto validate that the program exists and is executable.
471d6f907dcSJoerg WunschSpecifying a full path (or supplying a blank "" shell) avoids this check
472d6f907dcSJoerg Wunschand allows for such entries as
4731dcc6ec7SPhilippe Charnier.Pa /nonexistent
474d6f907dcSJoerg Wunschthat should be set for accounts not intended for interactive login.
475d6f907dcSJoerg Wunsch.It Fl h Ar fd
476d6f907dcSJoerg WunschThis option provides a special interface by which interactive scripts can
477d6f907dcSJoerg Wunschset an account password using
478e97407b4SRuslan Ermilov.Nm .
479137db389SSteve PriceBecause the command line and environment are fundamentally insecure mechanisms
480d6f907dcSJoerg Wunschby which programs can accept information,
4811dcc6ec7SPhilippe Charnier.Nm
482d6f907dcSJoerg Wunschwill only allow setting of account and group passwords via a file descriptor
483d6f907dcSJoerg Wunsch(usually a pipe between an interactive script and the program).
484d6f907dcSJoerg Wunsch.Ar sh ,
485d6f907dcSJoerg Wunsch.Ar bash ,
486d6f907dcSJoerg Wunsch.Ar ksh
487d6f907dcSJoerg Wunschand
488d6f907dcSJoerg Wunsch.Ar perl
489137db389SSteve Priceall possess mechanisms by which this can be done.
490d6f907dcSJoerg WunschAlternatively,
491325970a9SPhilippe Charnier.Nm
492d6f907dcSJoerg Wunschwill prompt for the user's password if
49308657612SRuslan Ermilov.Fl h Ar 0
494d6f907dcSJoerg Wunschis given, nominating
495d6f907dcSJoerg Wunsch.Em stdin
496d6f907dcSJoerg Wunschas the file descriptor on which to read the password.
497137db389SSteve PriceNote that this password will be read only once and is intended
498137db389SSteve Pricefor use by a script rather than for interactive use.
499d6f907dcSJoerg WunschIf you wish to have new password confirmation along the lines of
500d6f907dcSJoerg Wunsch.Xr passwd 1 ,
501137db389SSteve Pricethis must be implemented as part of an interactive script that calls
502e97407b4SRuslan Ermilov.Nm .
503d6f907dcSJoerg Wunsch.Pp
504d6f907dcSJoerg WunschIf a value of
505d6f907dcSJoerg Wunsch.Ql \&-
506d6f907dcSJoerg Wunschis given as the argument
507d6f907dcSJoerg Wunsch.Ar fd ,
508d6f907dcSJoerg Wunschthen the password will be set to
509d6f907dcSJoerg Wunsch.Ql \&* ,
510137db389SSteve Pricerendering the account inaccessible via password-based login.
51187d6b5caSIan Dowse.It Fl H Ar fd
51287d6b5caSIan DowseRead an encrypted password string from the specified file descriptor.
51387d6b5caSIan DowseThis is like
51487d6b5caSIan Dowse.Fl h ,
51587d6b5caSIan Dowsebut the password should be supplied already encrypted in a form
51687d6b5caSIan Dowsesuitable for writing directly to the password database.
517d6f907dcSJoerg Wunsch.El
518d6f907dcSJoerg Wunsch.Pp
519d6f907dcSJoerg WunschIt is possible to use
520d6f907dcSJoerg Wunsch.Ar useradd
521d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id.
522d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the
52308657612SRuslan Ermilov.Fl o
5249fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of
5259fd0dafcSJoerg Wunschthe user id.
5269fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under
5279fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home
5289fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same
5299fd0dafcSJoerg Wunschpermissions for access to the user's files in each account.
530d6f907dcSJoerg Wunsch.Pp
531d6f907dcSJoerg WunschThe
532d6f907dcSJoerg Wunsch.Ar useradd
533d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the
53408657612SRuslan Ermilov.Fl D
5359fd0dafcSJoerg Wunschoption.
536d6f907dcSJoerg WunschInstead of adding a new user,
5371dcc6ec7SPhilippe Charnier.Nm
538d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file,
539d6f907dcSJoerg Wunsch.Pa /etc/pw.conf .
540d6f907dcSJoerg WunschWhen using the
54108657612SRuslan Ermilov.Fl D
5429fd0dafcSJoerg Wunschoption, you must not use either
54308657612SRuslan Ermilov.Fl n Ar name
544d6f907dcSJoerg Wunschor
54508657612SRuslan Ermilov.Fl u Ar uid
546d6f907dcSJoerg Wunschor an error will result.
547d6f907dcSJoerg WunschUse of
54808657612SRuslan Ermilov.Fl D
5499fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the
550d6f907dcSJoerg Wunsch.Ar useradd
551d6f907dcSJoerg Wunschcommand.
552d6f907dcSJoerg WunschThese are:
553d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
554d6f907dcSJoerg Wunsch.It Fl D
555d6f907dcSJoerg WunschSet default values in
556d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
557d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the
55808657612SRuslan Ermilov.Fl C Ar config
5599fd0dafcSJoerg Wunschoption is used.
560d6f907dcSJoerg Wunsch.It Fl b Ar dir
5611dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created.
562d6f907dcSJoerg WunschThe default value for this is
5631dcc6ec7SPhilippe Charnier.Pa /home ,
564d6f907dcSJoerg Wunschbut it may be set elsewhere as desired.
565d6f907dcSJoerg Wunsch.It Fl e Ar days
5661dcc6ec7SPhilippe CharnierSet the default account expiration period in days.
567d6f907dcSJoerg WunschUnlike use without
56808657612SRuslan Ermilov.Fl D ,
569d6f907dcSJoerg Wunschthe argument must be numeric, which specifies the number of days after creation when
570d6f907dcSJoerg Wunschthe account is to expire.
571d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date.
572d6f907dcSJoerg Wunsch.It Fl p Ar days
5731dcc6ec7SPhilippe CharnierSet the default password expiration period in days.
574d6f907dcSJoerg Wunsch.It Fl g Ar group
5751dcc6ec7SPhilippe CharnierSet the default group for new users.
576d6f907dcSJoerg WunschIf a blank group is specified using
57708657612SRuslan Ermilov.Fl g Ar \&"" ,
578137db389SSteve Pricethen new users will be allocated their own private primary group
579137db389SSteve Pricewith the same name as their login name.
580d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument.
581d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
582137db389SSteve PriceSet the default groups in which new users are granted membership.
583d6f907dcSJoerg WunschThis is a separate set of groups from the primary group, and you should avoid
584137db389SSteve Pricenominating the same group as both primary and extra groups.
585d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups
586d6f907dcSJoerg Wunsch.Em other than
587d6f907dcSJoerg Wunschthe primary group.
588d6f907dcSJoerg Wunsch.Ar grouplist
589137db389SSteve Priceis a comma-separated list of group names or ids, and are always
590d6f907dcSJoerg Wunschstored in
591d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
592d6f907dcSJoerg Wunschby their symbolic names.
5939fd0dafcSJoerg Wunsch.It Fl L Ar class
5949fd0dafcSJoerg WunschThis option sets the default login class for new users.
595d6f907dcSJoerg Wunsch.It Fl k Ar dir
5961dcc6ec7SPhilippe CharnierSet the default
597d6f907dcSJoerg Wunsch.Em skeleton
598053375e8SMike Pritcharddirectory, from which prototype shell and other initialization files are copied when
5991dcc6ec7SPhilippe Charnier.Nm
600d6f907dcSJoerg Wunschcreates a user's home directory.
601610a5778SRuslan Ermilov.It Xo
602610a5778SRuslan Ermilov.Fl u Ar min , Ns Ar max ,
603610a5778SRuslan Ermilov.Fl i Ar min , Ns Ar max
604610a5778SRuslan Ermilov.Xc
6059fd0dafcSJoerg WunschThese options set the minimum and maximum user and group ids allocated for new accounts
606d6f907dcSJoerg Wunschand groups created by
607e97407b4SRuslan Ermilov.Nm .
608d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum.
609d6f907dcSJoerg Wunsch.Ar min
610d6f907dcSJoerg Wunschand
611d6f907dcSJoerg Wunsch.Ar max
612d6f907dcSJoerg Wunschare both numbers, where max must be greater than min, and both must be between 0
613d6f907dcSJoerg Wunschand 32767.
614d6f907dcSJoerg WunschIn general, user and group ids less than 100 are reserved for use by the system,
615d6f907dcSJoerg Wunschand numbers greater than 32000 may also be reserved for special purposes (used by
616d6f907dcSJoerg Wunschsome system daemons).
617d6f907dcSJoerg Wunsch.It Fl w Ar method
618d6f907dcSJoerg WunschThe
61908657612SRuslan Ermilov.Fl w
6209fd0dafcSJoerg Wunschoption sets the default method used to set passwords for newly created user accounts.
621d6f907dcSJoerg Wunsch.Ar method
622d6f907dcSJoerg Wunschis one of:
623d6f907dcSJoerg Wunsch.Pp
624d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact
625d6f907dcSJoerg Wunsch.It no
6261dcc6ec7SPhilippe Charnierdisable login on newly created accounts
627d6f907dcSJoerg Wunsch.It yes
6281dcc6ec7SPhilippe Charnierforce the password to be the account name
629d6f907dcSJoerg Wunsch.It none
6301dcc6ec7SPhilippe Charnierforce a blank password
631d6f907dcSJoerg Wunsch.It random
6321dcc6ec7SPhilippe Charniergenerate a random password
633d6f907dcSJoerg Wunsch.El
634d6f907dcSJoerg Wunsch.Pp
635d6f907dcSJoerg WunschThe
636d6f907dcSJoerg Wunsch.Ql \&random
637d6f907dcSJoerg Wunschor
638d6f907dcSJoerg Wunsch.Ql \&no
639d6f907dcSJoerg Wunschmethods are the most secure; in the former case,
6401dcc6ec7SPhilippe Charnier.Nm
641d6f907dcSJoerg Wunschgenerates a password and prints it to stdout, which is suitable where you issue
642d6f907dcSJoerg Wunschusers with passwords to access their accounts rather than having the user nominate
643d6f907dcSJoerg Wunschtheir own (possibly poorly chosen) password.
644d6f907dcSJoerg WunschThe
645d6f907dcSJoerg Wunsch.Ql \&no
646d6f907dcSJoerg Wunschmethod requires that the superuser use
647d6f907dcSJoerg Wunsch.Xr passwd 1
648d6f907dcSJoerg Wunschto render the account accessible with a password.
649f1d684faSDavid Nugent.It Fl y Ar path
650490d5836SPhilippe CharnierThis sets the pathname of the database used by
651490d5836SPhilippe Charnier.Tn NIS
652490d5836SPhilippe Charnierif you are not sharing
653f1d684faSDavid Nugentthe information from
654f1d684faSDavid Nugent.Pa /etc/master.passwd
655490d5836SPhilippe Charnierdirectly with
656490d5836SPhilippe Charnier.Tn NIS .
657490d5836SPhilippe CharnierYou should only set this option for
658490d5836SPhilippe Charnier.Tn NIS
659490d5836SPhilippe Charnierservers.
660d6f907dcSJoerg Wunsch.El
661d6f907dcSJoerg Wunsch.Pp
662d6f907dcSJoerg WunschThe
663d6f907dcSJoerg Wunsch.Ar userdel
664f2e366a1SSheldon Hearncommand has only three valid options.
665f2e366a1SSheldon HearnThe
66608657612SRuslan Ermilov.Fl n Ar name
667d6f907dcSJoerg Wunschand
66808657612SRuslan Ermilov.Fl u Ar uid
6699fd0dafcSJoerg Wunschoptions have already been covered above.
6709fd0dafcSJoerg WunschThe additional option is:
6719fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
672d6f907dcSJoerg Wunsch.It Fl r
673d6f907dcSJoerg WunschThis tells
6741dcc6ec7SPhilippe Charnier.Nm
675d6f907dcSJoerg Wunschto remove the user's home directory and all of its contents.
676490d5836SPhilippe CharnierThe
677490d5836SPhilippe Charnier.Nm
678490d5836SPhilippe Charnierutility errs on the side of caution when removing files from the system.
679d6f907dcSJoerg WunschFirstly, it will not do so if the uid of the account being removed is also used by
680d6f907dcSJoerg Wunschanother account on the system, and the 'home' directory in the password file is
681d6f907dcSJoerg Wunscha valid path that commences with the character
682d6f907dcSJoerg Wunsch.Ql \&/ .
683d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by
684d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory.
685d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories
686d6f907dcSJoerg Wunschwill be removed.
687053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator.
688d6f907dcSJoerg Wunsch.El
689d6f907dcSJoerg Wunsch.Pp
690d6f907dcSJoerg WunschMail spool files and crontabs are always removed when an account is deleted as these
691d6f907dcSJoerg Wunschare unconditionally attached to the user name.
692d6f907dcSJoerg WunschJobs queued for processing by
693d6f907dcSJoerg Wunsch.Ar at
694137db389SSteve Priceare also removed if the user's uid is unique and not also used by another account on the
695137db389SSteve Pricesystem.
696d6f907dcSJoerg Wunsch.Pp
697d6f907dcSJoerg WunschThe
698d6f907dcSJoerg Wunsch.Ar usershow
699d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats.
700d6f907dcSJoerg WunschBy default, the format is identical to the format used in
701d6f907dcSJoerg Wunsch.Pa /etc/master.passwd
702d6f907dcSJoerg Wunschwith the password field replaced with a
703d6f907dcSJoerg Wunsch.Ql \&* .
704d6f907dcSJoerg WunschIf the
70508657612SRuslan Ermilov.Fl P
7069fd0dafcSJoerg Wunschoption is used, then
7071dcc6ec7SPhilippe Charnier.Nm
708d6f907dcSJoerg Wunschoutputs the account details in a more human readable form.
7094731d076SDima DorfmanIf the
7104731d076SDima Dorfman.Fl 7
7114731d076SDima Dorfmanoption is used, the account details are shown in v7 format.
712d6f907dcSJoerg WunschThe
71308657612SRuslan Ermilov.Fl a
7149fd0dafcSJoerg Wunschoption lists all users currently on file.
715466c257cSDima DorfmanUsing
716466c257cSDima Dorfman.Fl F
717466c257cSDima Dorfmanforces
718466c257cSDima Dorfman.Nm
719466c257cSDima Dorfmanto print the details of an account even if it does not exist.
7209fd0dafcSJoerg Wunsch.Pp
7219fd0dafcSJoerg WunschThe command
7229fd0dafcSJoerg Wunsch.Ar usernext
7239fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon.
7249fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends
7259fd0dafcSJoerg Wunschthat use
726e97407b4SRuslan Ermilov.Nm .
727d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS
728d6f907dcSJoerg WunschThe
72908657612SRuslan Ermilov.Fl C
730d6f907dcSJoerg Wunschand
73108657612SRuslan Ermilov.Fl q
7329fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available
7339fd0dafcSJoerg Wunschwith the group manipulation commands.
734d6f907dcSJoerg WunschOther common options to all group-related commands are:
7359fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
736d6f907dcSJoerg Wunsch.It Fl n Ar name
7371dcc6ec7SPhilippe CharnierSpecify the group name.
738d6f907dcSJoerg Wunsch.It Fl g Ar gid
7391dcc6ec7SPhilippe CharnierSpecify the group numeric id.
740d6f907dcSJoerg Wunsch.Pp
7419fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need
7429fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice
7439fd0dafcSJoerg Wunschversa.
7449fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id
7459fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group.
7467ecd7a42SJoseph Koshy.It Fl M Ar memberlist
7479fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a
7489fd0dafcSJoerg Wunschnew group (in groupadd) or replace an existing membership list (in
7499fd0dafcSJoerg Wunschgroupmod).
7509fd0dafcSJoerg Wunsch.Ar memberlist
7519fd0dafcSJoerg Wunschis a comma separated list of valid and existing user names or uids.
7529fd0dafcSJoerg Wunsch.It Fl m Ar newmembers
7539fd0dafcSJoerg WunschSimilar to
75408657612SRuslan Ermilov.Fl M ,
7559fd0dafcSJoerg Wunschthis option allows the
7569fd0dafcSJoerg Wunsch.Em addition
757137db389SSteve Priceof existing users to a group without replacing the existing list of
7589fd0dafcSJoerg Wunschmembers.
759137db389SSteve PriceLogin names or user ids may be used, and duplicate users are
760137db389SSteve Pricesilently eliminated.
761d6f907dcSJoerg Wunsch.El
762d6f907dcSJoerg Wunsch.Pp
763d6f907dcSJoerg Wunsch.Ar groupadd
764d6f907dcSJoerg Wunschalso has a
76508657612SRuslan Ermilov.Fl o
766137db389SSteve Priceoption that allows allocation of an existing group id to a new group.
767d6f907dcSJoerg WunschThe default action is to reject an attempt to add a group, and this option overrides
768d6f907dcSJoerg Wunschthe check for duplicate group ids.
769d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id.
770d6f907dcSJoerg Wunsch.Pp
771d6f907dcSJoerg WunschThe
772d6f907dcSJoerg Wunsch.Ar groupmod
773137db389SSteve Pricecommand adds one additional option:
774d6f907dcSJoerg Wunsch.Pp
7759fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
776d6f907dcSJoerg Wunsch.It Fl l Ar name
777d6f907dcSJoerg WunschThis option allows changing of an existing group name to
778d6f907dcSJoerg Wunsch.Ql \&name .
779d6f907dcSJoerg WunschThe new name must not already exist, and any attempt to duplicate an existing group
780d6f907dcSJoerg Wunschname will be rejected.
781d6f907dcSJoerg Wunsch.El
782d6f907dcSJoerg Wunsch.Pp
783d6f907dcSJoerg WunschOptions for
784d6f907dcSJoerg Wunsch.Ar groupshow
785d6f907dcSJoerg Wunschare the same as for
786d6f907dcSJoerg Wunsch.Ar usershow ,
787d6f907dcSJoerg Wunschwith the
78808657612SRuslan Ermilov.Fl g Ar gid
789d6f907dcSJoerg Wunschreplacing
79008657612SRuslan Ermilov.Fl u Ar uid
791d6f907dcSJoerg Wunschto specify the group id.
7924731d076SDima DorfmanThe
7934731d076SDima Dorfman.Fl 7
7944731d076SDima Dorfmanoption does not apply to the
7954731d076SDima Dorfman.Ar groupshow
7964731d076SDima Dorfmancommand.
797d6f907dcSJoerg Wunsch.Pp
7989fd0dafcSJoerg WunschThe command
7999fd0dafcSJoerg Wunsch.Ar groupnext
8009fd0dafcSJoerg Wunschreturns the next available group id on standard output.
801e468afb4SDima Dorfman.Sh USER LOCKING
802490d5836SPhilippe CharnierThe
803490d5836SPhilippe Charnier.Nm
804490d5836SPhilippe Charnierutility
805e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by
806e468afb4SDima Dorfmanprepending the string
807e468afb4SDima Dorfman.Ql *LOCKED*
808e468afb4SDima Dorfmanto the beginning of the password field in
809e468afb4SDima Dorfman.Pa master.passwd
810e468afb4SDima Dorfmanto prevent successful authentication.
811e468afb4SDima Dorfman.Pp
812e468afb4SDima DorfmanThe
813e468afb4SDima Dorfman.Ar lock
814e468afb4SDima Dorfmanand
815e468afb4SDima Dorfman.Ar unlock
816e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock,
817e468afb4SDima Dorfmanrespectively.  The
81808657612SRuslan Ermilov.Fl V ,
81908657612SRuslan Ermilov.Fl C ,
820e468afb4SDima Dorfmanand
82108657612SRuslan Ermilov.Fl q
822e468afb4SDima Dorfmanoptions as described above are accepted by these commands.
8239fd0dafcSJoerg Wunsch.Sh DIAGNOSTICS
824490d5836SPhilippe CharnierThe
825490d5836SPhilippe Charnier.Nm
826490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise
827137db389SSteve Price.Nm
828137db389SSteve Pricereturns one of the
8299fd0dafcSJoerg Wunschfollowing exit codes defined by
8309fd0dafcSJoerg Wunsch.Xr sysexits 3
8319fd0dafcSJoerg Wunschas follows:
8329fd0dafcSJoerg Wunsch.Bl -tag -width xxxx
8339fd0dafcSJoerg Wunsch.It EX_USAGE
8349fd0dafcSJoerg Wunsch.Bl -bullet -compact
8359fd0dafcSJoerg Wunsch.It
8361dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option).
8379fd0dafcSJoerg Wunsch.El
8389fd0dafcSJoerg Wunsch.It EX_NOPERM
8399fd0dafcSJoerg Wunsch.Bl -bullet -compact
8409fd0dafcSJoerg Wunsch.It
8419fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root.
8429fd0dafcSJoerg Wunsch.El
8439fd0dafcSJoerg Wunsch.It EX_OSERR
8449fd0dafcSJoerg Wunsch.Bl -bullet -compact
8459fd0dafcSJoerg Wunsch.It
8469fd0dafcSJoerg WunschMemory allocation error.
8479fd0dafcSJoerg Wunsch.It
8489fd0dafcSJoerg WunschRead error from password file descriptor.
8499fd0dafcSJoerg Wunsch.El
8509fd0dafcSJoerg Wunsch.It EX_DATAERR
8519fd0dafcSJoerg Wunsch.Bl -bullet -compact
8529fd0dafcSJoerg Wunsch.It
8539fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or
854137db389SSteve Pricevia the password file descriptor.
8559fd0dafcSJoerg Wunsch.It
8569fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid.
8579fd0dafcSJoerg Wunsch.El
8589fd0dafcSJoerg Wunsch.It EX_OSFILE
8599fd0dafcSJoerg Wunsch.Bl -bullet -compact
8609fd0dafcSJoerg Wunsch.It
8619fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist.
8629fd0dafcSJoerg Wunsch.It
8639fd0dafcSJoerg WunschBase home directory is invalid or does not exist.
8649fd0dafcSJoerg Wunsch.It
865137db389SSteve PriceInvalid or non-existent shell specified.
8669fd0dafcSJoerg Wunsch.El
8679fd0dafcSJoerg Wunsch.It EX_NOUSER
8689fd0dafcSJoerg Wunsch.Bl -bullet -compact
8699fd0dafcSJoerg Wunsch.It
8709fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist.
8719fd0dafcSJoerg Wunsch.It
872137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared.
8739fd0dafcSJoerg Wunsch.El
8749fd0dafcSJoerg Wunsch.It EX_SOFTWARE
8759fd0dafcSJoerg Wunsch.Bl -bullet -compact
8769fd0dafcSJoerg Wunsch.It
8779fd0dafcSJoerg WunschNo more group or user ids available within specified range.
8789fd0dafcSJoerg Wunsch.El
8799fd0dafcSJoerg Wunsch.It EX_IOERR
8809fd0dafcSJoerg Wunsch.Bl -bullet -compact
8819fd0dafcSJoerg Wunsch.It
8829fd0dafcSJoerg WunschUnable to rewrite configuration file.
8839fd0dafcSJoerg Wunsch.It
8849fd0dafcSJoerg WunschError updating group or user database files.
8859fd0dafcSJoerg Wunsch.It
8869fd0dafcSJoerg WunschUpdate error for passwd or group database files.
8879fd0dafcSJoerg Wunsch.El
8889fd0dafcSJoerg Wunsch.It EX_CONFIG
8899fd0dafcSJoerg Wunsch.Bl -bullet -compact
8909fd0dafcSJoerg Wunsch.It
8919fd0dafcSJoerg WunschNo base home directory configured.
8929fd0dafcSJoerg Wunsch.El
8939fd0dafcSJoerg Wunsch.El
894d6f907dcSJoerg Wunsch.Sh NOTES
895d6f907dcSJoerg WunschFor a summary of options available with each command, you can use
896d6f907dcSJoerg Wunsch.Dl pw [command] help
897d6f907dcSJoerg WunschFor example,
898d6f907dcSJoerg Wunsch.Dl pw useradd help
899d6f907dcSJoerg Wunschlists all available options for the useradd operation.
900d9b711b7SDavid Nugent.Pp
901490d5836SPhilippe CharnierThe
902490d5836SPhilippe Charnier.Nm
903490d5836SPhilippe Charnierutility allows 8-bit characters in the passwd GECOS field (user's full name,
904d9b711b7SDavid Nugentoffice, work and home phone number subfields), but disallows them in
905d9b711b7SDavid Nugentuser login and group names.
906137db389SSteve PriceUse 8-bit characters with caution, as connection to the Internet will
907d9b711b7SDavid Nugentrequire that your mail transport program supports 8BITMIME, and will
908d9b711b7SDavid Nugentconvert headers containing 8-bit characters to 7-bit quoted-printable
909d9b711b7SDavid Nugentformat.
910d9b711b7SDavid Nugent.Xr sendmail 8
911d9b711b7SDavid Nugentdoes support this.
912137db389SSteve PriceUse of 8-bit characters in the GECOS field should be used in
913d9b711b7SDavid Nugentconjunction with the user's default locale and character set
914d9b711b7SDavid Nugentand should not be implemented without their use.
915d9b711b7SDavid NugentUsing 8-bit characters may also affect other
916137db389SSteve Priceprograms that transmit the contents of the GECOS field over the
917137db389SSteve PriceInternet, such as
918d9b711b7SDavid Nugent.Xr fingerd 8 ,
919137db389SSteve Priceand a small number of TCP/IP clients, such as IRC, where full names
920d9b711b7SDavid Nugentspecified in the passwd file may be used by default.
9210603fbc3STom Rhodes.Pp
9220603fbc3STom RhodesThe
9230603fbc3STom Rhodes.Nm
9240603fbc3STom Rhodesutility writes a log to the
9250603fbc3STom Rhodes.Pa /var/log/userlog
9260603fbc3STom Rhodesfile when actions such as user or group additions or deletions occur.
9270603fbc3STom RhodesThe location of this logfile can be changed in
9280603fbc3STom Rhodes.Xr pw.conf 5 .
929d6f907dcSJoerg Wunsch.Sh FILES
930d6f907dcSJoerg Wunsch.Bl -tag -width /etc/master.passwd.new -compact
931d6f907dcSJoerg Wunsch.It Pa /etc/master.passwd
932d6f907dcSJoerg WunschThe user database
933d6f907dcSJoerg Wunsch.It Pa /etc/passwd
934d6f907dcSJoerg WunschA Version 7 format password file
9359fd0dafcSJoerg Wunsch.It Pa /etc/login.conf
9369fd0dafcSJoerg WunschThe user capabilities database
937d6f907dcSJoerg Wunsch.It Pa /etc/group
938d6f907dcSJoerg WunschThe group database
939d6f907dcSJoerg Wunsch.It Pa /etc/master.passwd.new
940d6f907dcSJoerg WunschTemporary copy of the master password file
941d6f907dcSJoerg Wunsch.It Pa /etc/passwd.new
942d6f907dcSJoerg WunschTemporary copy of the Version 7 password file
943d6f907dcSJoerg Wunsch.It Pa /etc/group.new
944d6f907dcSJoerg WunschTemporary copy of the group file
945d6f907dcSJoerg Wunsch.It Pa /etc/pw.conf
946d6f907dcSJoerg WunschPw default options file
9470603fbc3STom Rhodes.It Pa /var/log/userlog
9480603fbc3STom RhodesUser/group modification logfile
949d6f907dcSJoerg Wunsch.El
950d6f907dcSJoerg Wunsch.Sh SEE ALSO
951d6f907dcSJoerg Wunsch.Xr chpass 1 ,
952053375e8SMike Pritchard.Xr passwd 1 ,
953d6f907dcSJoerg Wunsch.Xr group 5 ,
954bfd34a4aSWolfram Schneider.Xr login.conf 5 ,
955053375e8SMike Pritchard.Xr passwd 5 ,
956053375e8SMike Pritchard.Xr pw.conf 5 ,
957d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 ,
958053375e8SMike Pritchard.Xr vipw 8
959d6f907dcSJoerg Wunsch.Sh HISTORY
960490d5836SPhilippe CharnierThe
961490d5836SPhilippe Charnier.Nm
962490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV
963d6f907dcSJoerg Wunsch.Em shadow
9649fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to
965053375e8SMike Pritchardthe
966053375e8SMike Pritchard.Bx 4.4
9679fd0dafcSJoerg Wunschoperating system, and combines all of the major elements
9689fd0dafcSJoerg Wunschinto a single command.
969