]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - usr.sbin/pw/pw.8
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / usr.sbin / pw / pw.8
1 .\" Copyright (C) 1996
2 .\" David L. Nugent.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd March 30, 2007
28 .Dt PW 8
29 .Os
30 .Sh NAME
31 .Nm pw
32 .Nd create, remove, modify & display system users and groups
33 .Sh SYNOPSIS
34 .Nm
35 .Op Fl V Ar etcdir
36 .Ar useradd
37 .Op name|uid
38 .Op Fl C Ar config
39 .Op Fl q
40 .Op Fl n Ar name
41 .Op Fl u Ar uid
42 .Op Fl c Ar comment
43 .Op Fl d Ar dir
44 .Op Fl e Ar date
45 .Op Fl p Ar date
46 .Op Fl g Ar group
47 .Op Fl G Ar grouplist
48 .Op Fl m
49 .Op Fl M Ar mode
50 .Op Fl k Ar dir
51 .Op Fl w Ar method
52 .Op Fl s Ar shell
53 .Op Fl o
54 .Op Fl L Ar class
55 .Op Fl h Ar fd | Fl H Ar fd
56 .Op Fl N
57 .Op Fl P
58 .Op Fl Y
59 .Nm
60 .Op Fl V Ar etcdir
61 .Ar useradd
62 .Op name|uid
63 .Fl D
64 .Op Fl C Ar config
65 .Op Fl q
66 .Op Fl b Ar dir
67 .Op Fl e Ar days
68 .Op Fl p Ar days
69 .Op Fl g Ar group
70 .Op Fl G Ar grouplist
71 .Op Fl k Ar dir
72 .Op Fl M Ar mode
73 .Op Fl u Ar min , Ns Ar max
74 .Op Fl i Ar min , Ns Ar max
75 .Op Fl w Ar method
76 .Op Fl s Ar shell
77 .Op Fl y Ar path
78 .Nm
79 .Op Fl V Ar etcdir
80 .Ar userdel
81 .Op name|uid
82 .Op Fl n Ar name
83 .Op Fl u Ar uid
84 .Op Fl r
85 .Op Fl Y
86 .Nm
87 .Op Fl V Ar etcdir
88 .Ar usermod
89 .Op name|uid
90 .Op Fl C Ar config
91 .Op Fl q
92 .Op Fl n Ar name
93 .Op Fl u Ar uid
94 .Op Fl c Ar comment
95 .Op Fl d Ar dir
96 .Op Fl e Ar date
97 .Op Fl p Ar date
98 .Op Fl g Ar group
99 .Op Fl G Ar grouplist
100 .Op Fl l Ar name
101 .Op Fl m
102 .Op Fl M Ar mode
103 .Op Fl k Ar dir
104 .Op Fl w Ar method
105 .Op Fl s Ar shell
106 .Op Fl L Ar class
107 .Op Fl h Ar fd | Fl H Ar fd
108 .Op Fl N
109 .Op Fl P
110 .Op Fl Y
111 .Nm
112 .Op Fl V Ar etcdir
113 .Ar usershow
114 .Op name|uid
115 .Op Fl n Ar name
116 .Op Fl u Ar uid
117 .Op Fl F
118 .Op Fl P
119 .Op Fl 7
120 .Op Fl a
121 .Nm
122 .Op Fl V Ar etcdir
123 .Ar usernext
124 .Op Fl C Ar config
125 .Op Fl q
126 .Nm
127 .Op Fl V Ar etcdir
128 .Ar groupadd
129 .Op group|gid
130 .Op Fl C Ar config
131 .Op Fl q
132 .Op Fl n Ar group
133 .Op Fl g Ar gid
134 .Op Fl M Ar members
135 .Op Fl o
136 .Op Fl h Ar fd | Fl H Ar fd
137 .Op Fl N
138 .Op Fl P
139 .Op Fl Y
140 .Nm
141 .Op Fl V Ar etcdir
142 .Ar groupdel
143 .Op group|gid
144 .Op Fl n Ar name
145 .Op Fl g Ar gid
146 .Op Fl Y
147 .Nm
148 .Op Fl V Ar etcdir
149 .Ar groupmod
150 .Op group|gid
151 .Op Fl C Ar config
152 .Op Fl q
153 .Op Fl n Ar name
154 .Op Fl g Ar gid
155 .Op Fl l Ar name
156 .Op Fl M Ar members
157 .Op Fl m Ar newmembers
158 .Op Fl d Ar oldmembers
159 .Op Fl h Ar fd | Fl H Ar fd
160 .Op Fl N
161 .Op Fl P
162 .Op Fl Y
163 .Nm
164 .Op Fl V Ar etcdir
165 .Ar groupshow
166 .Op group|gid
167 .Op Fl n Ar name
168 .Op Fl g Ar gid
169 .Op Fl F
170 .Op Fl P
171 .Op Fl a
172 .Nm
173 .Op Fl V Ar etcdir
174 .Ar groupnext
175 .Op Fl C Ar config
176 .Op Fl q
177 .Nm
178 .Op Fl V Ar etcdir
179 .Ar lock
180 .Op name|uid
181 .Op Fl C Ar config
182 .Op Fl q
183 .Nm
184 .Op Fl V Ar etcdir
185 .Ar unlock
186 .Op name|uid
187 .Op Fl C Ar config
188 .Op Fl q
189 .Sh DESCRIPTION
190 The
191 .Nm
192 utility is a command-line based editor for the system
193 .Ar user
194 and
195 .Ar group
196 files, allowing the superuser an easy to use and standardized way of adding,
197 modifying and removing users and groups.
198 Note that
199 .Nm
200 only operates on the local user and group files.
201 .Tn NIS
202 users and groups must be
203 maintained on the
204 .Tn NIS
205 server.
206 The
207 .Nm
208 utility handles updating the
209 .Pa passwd ,
210 .Pa master.passwd ,
211 .Pa group
212 and the secure and insecure
213 password database files, and must be run as root.
214 .Pp
215 The first one or two keywords provided to
216 .Nm
217 on the command line provide the context for the remainder of the arguments.
218 The keywords
219 .Ar user
220 and
221 .Ar group
222 may be combined with
223 .Ar add ,
224 .Ar del ,
225 .Ar mod ,
226 .Ar show ,
227 or
228 .Ar next
229 in any order.
230 (For example,
231 .Ar showuser ,
232 .Ar usershow ,
233 .Ar show user ,
234 and
235 .Ar user show
236 all mean the same thing.)
237 This flexibility is useful for interactive scripts calling
238 .Nm
239 for user and group database manipulation.
240 Following these keywords, you may optionally specify the user or group name or numeric
241 id as an alternative to using the
242 .Fl n Ar name ,
243 .Fl u Ar uid ,
244 .Fl g Ar gid
245 options.
246 .Pp
247 The following flags are common to most or all modes of operation:
248 .Pp
249 .Bl -tag -width "-G grouplist"
250 .It Fl V Ar etcdir
251 This flag sets an alternate location for the password, group and configuration files,
252 and may be used to maintain a user/group database in an alternate location.
253 If this switch is specified, the system
254 .Pa /etc/pw.conf
255 will not be sourced for default configuration data, but the file pw.conf in the
256 specified directory will be used instead (or none, if it does not exist).
257 The
258 .Fl C
259 flag may be used to override this behaviour.
260 As an exception to the general rule where options must follow the operation
261 type, the
262 .Fl V
263 flag may be used on the command line before the operation keyword.
264 .It Fl C Ar config
265 By default,
266 .Nm
267 reads the file
268 .Pa /etc/pw.conf
269 to obtain policy information on how new user accounts and groups are to be created.
270 The
271 .Fl C
272 option specifies a different configuration file.
273 While most of the contents of the configuration file may be overridden via
274 command-line options, it may be more convenient to keep standard information in a
275 configuration file.
276 .It Fl q
277 Use of this option causes
278 .Nm
279 to suppress error messages, which may be useful in interactive environments where it
280 is preferable to interpret status codes returned by
281 .Nm
282 rather than messing up a carefully formatted display.
283 .It Fl N
284 This option is available in
285 .Ar add
286 and
287 .Ar modify
288 operations, and tells
289 .Nm
290 to output the result of the operation without updating the user or group
291 databases.
292 You may use the
293 .Fl P
294 option to switch between standard passwd and readable formats.
295 .It Fl Y
296 Using this option with any of the update modes causes
297 .Nm
298 to run
299 .Xr make 1
300 after changing to the directory
301 .Pa /var/yp .
302 This is intended to allow automatic updating of
303 .Tn NIS
304 database files.
305 If separate passwd and group files are being used by
306 .Tn NIS ,
307 then use the
308 .Fl y Ar path
309 option to specify the location of the
310 .Tn NIS
311 passwd database so that
312 .Nm
313 will concurrently update it with the system password
314 databases.
315 .El
316 .Sh USER OPTIONS
317 The following options apply to the
318 .Ar useradd
319 and
320 .Ar usermod
321 commands:
322 .Pp
323 .Bl -tag -width "-G grouplist"
324 .It Fl n Ar name
325 Specify the user/account name.
326 .It Fl u Ar uid
327 Specify the user/account numeric id.
328 .Pp
329 Usually, you only need to provide one or the other of these options, as the account
330 name will imply the uid, or vice versa.
331 However, there are times when you need to provide both.
332 For example, when changing the uid of an existing user with
333 .Ar usermod ,
334 or overriding the default uid when creating a new account.
335 If you wish
336 .Nm
337 to automatically allocate the uid to a new user with
338 .Ar useradd ,
339 then you should
340 .Em not
341 use the
342 .Fl u
343 option.
344 You may also provide either the account or userid immediately after the
345 .Ar useradd ,
346 .Ar userdel ,
347 .Ar usermod
348 or
349 .Ar usershow
350 keywords on the command line without using the
351 .Fl n
352 or
353 .Fl u
354 options.
355 .El
356 .Pp
357 .Bl -tag -width "-G grouplist"
358 .It Fl c Ar comment
359 This field sets the contents of the passwd GECOS field, which normally contains up
360 to four comma-separated fields containing the user's full name, office or location,
361 and work and home phone numbers.
362 These sub-fields are used by convention only, however, and are optional.
363 If this field is to contain spaces, you need to quote the comment itself with double
364 quotes
365 .Ql \&" .
366 Avoid using commas in this field as these are used as sub-field separators, and the
367 colon
368 .Ql \&:
369 character also cannot be used as this is the field separator for the passwd
370 file itself.
371 .It Fl d Ar dir
372 This option sets the account's home directory.
373 Normally, you will only use this if the home directory is to be different from the
374 default determined from
375 .Pa /etc/pw.conf
376 - normally
377 .Pa /home
378 with the account name as a subdirectory.
379 .It Fl e Ar date
380 Set the account's expiration date.
381 Format of the date is either a UNIX time in decimal, or a date in
382 .Ql dd-mmm-yy[yy]
383 format, where dd is the day, mmm is the month, either in numeric or alphabetic format
384 ('Jan', 'Feb', etc) and year is either a two or four digit year.
385 This option also accepts a relative date in the form
386 .Ql \&+n[mhdwoy]
387 where
388 .Ql \&n
389 is a decimal, octal (leading 0) or hexadecimal (leading 0x) digit followed by the
390 number of Minutes, Hours, Days, Weeks, Months or Years from the current date at
391 which the expiration date is to be set.
392 .It Fl p Ar date
393 Set the account's password expiration date.
394 This field is similar to the account expiration date option, except that it
395 applies to forced password changes.
396 This is set in the same manner as the
397 .Fl e
398 option.
399 .It Fl g Ar group
400 Set the account's primary group to the given group.
401 .Ar group
402 may be defined by either its name or group number.
403 .It Fl G Ar grouplist
404 Set additional group memberships for an account.
405 .Ar grouplist
406 is a comma, space or tab-separated list of group names or group numbers.
407 The user's name is added to the group lists in
408 .Pa /etc/group ,
409 and
410 removed from any groups not specified in
411 .Ar grouplist .
412 Note: a user should not be added to their primary group with
413 .Ar grouplist .
414 Also, group membership changes do not take effect for current user login
415 sessions, requiring the user to reconnect to be affected by the changes.
416 .It Fl L Ar class
417 This option sets the login class for the user being created.
418 See
419 .Xr login.conf 5
420 and
421 .Xr passwd 5
422 for more information on user login classes.
423 .It Fl m
424 This option instructs
425 .Nm
426 to attempt to create the user's home directory.
427 While primarily useful when adding a new account with
428 .Ar useradd ,
429 this may also be of use when moving an existing user's home directory elsewhere on
430 the file system.
431 The new home directory is populated with the contents of the
432 .Ar skeleton
433 directory, which typically contains a set of shell configuration files that the
434 user may personalize to taste.
435 Files in this directory are usually named
436 .Pa dot . Ns Aq Ar config
437 where the
438 .Pa dot
439 prefix will be stripped.
440 When
441 .Fl m
442 is used on an account with
443 .Ar usermod ,
444 existing configuration files in the user's home directory are
445 .Em not
446 overwritten from the skeleton files.
447 .Pp
448 When a user's home directory is created, it will by default be a subdirectory of the
449 .Ar basehome
450 directory as specified by the
451 .Fl b
452 option (see below), bearing the name of the new account.
453 This can be overridden by the
454 .Fl d
455 option on the command line, if desired.
456 .It Fl M Ar mode
457 Create the user's home directory with the specified
458 .Ar mode ,
459 modified by the current
460 .Xr umask 2 .
461 If omitted, it is derived from the parent process'
462 .Xr umask 2 .
463 This option is only useful in combination with the
464 .Fl m
465 flag.
466 .It Fl k Ar dir
467 Set the
468 .Ar skeleton
469 directory, from which basic startup and configuration files are copied when
470 the user's home directory is created.
471 This option only has meaning when used with the
472 .Fl d
473 or
474 .Fl m
475 flags.
476 .It Fl s Ar shell
477 Set or changes the user's login shell to
478 .Ar shell .
479 If the path to the shell program is omitted,
480 .Nm
481 searches the
482 .Ar shellpath
483 specified in
484 .Pa /etc/pw.conf
485 and fills it in as appropriate.
486 Note that unless you have a specific reason to do so, you should avoid
487 specifying the path - this will allow
488 .Nm
489 to validate that the program exists and is executable.
490 Specifying a full path (or supplying a blank "" shell) avoids this check
491 and allows for such entries as
492 .Pa /nonexistent
493 that should be set for accounts not intended for interactive login.
494 .It Fl h Ar fd
495 This option provides a special interface by which interactive scripts can
496 set an account password using
497 .Nm .
498 Because the command line and environment are fundamentally insecure mechanisms
499 by which programs can accept information,
500 .Nm
501 will only allow setting of account and group passwords via a file descriptor
502 (usually a pipe between an interactive script and the program).
503 .Ar sh ,
504 .Ar bash ,
505 .Ar ksh
506 and
507 .Ar perl
508 all possess mechanisms by which this can be done.
509 Alternatively,
510 .Nm
511 will prompt for the user's password if
512 .Fl h Ar 0
513 is given, nominating
514 .Em stdin
515 as the file descriptor on which to read the password.
516 Note that this password will be read only once and is intended
517 for use by a script rather than for interactive use.
518 If you wish to have new password confirmation along the lines of
519 .Xr passwd 1 ,
520 this must be implemented as part of an interactive script that calls
521 .Nm .
522 .Pp
523 If a value of
524 .Ql \&-
525 is given as the argument
526 .Ar fd ,
527 then the password will be set to
528 .Ql \&* ,
529 rendering the account inaccessible via password-based login.
530 .It Fl H Ar fd
531 Read an encrypted password string from the specified file descriptor.
532 This is like
533 .Fl h ,
534 but the password should be supplied already encrypted in a form
535 suitable for writing directly to the password database.
536 .El
537 .Pp
538 It is possible to use
539 .Ar useradd
540 to create a new account that duplicates an existing user id.
541 While this is normally considered an error and will be rejected, the
542 .Fl o
543 option overrides the check for duplicates and allows the duplication of
544 the user id.
545 This may be useful if you allow the same user to login under
546 different contexts (different group allocations, different home
547 directory, different shell) while providing basically the same
548 permissions for access to the user's files in each account.
549 .Pp
550 The
551 .Ar useradd
552 command also has the ability to set new user and group defaults by using the
553 .Fl D
554 option.
555 Instead of adding a new user,
556 .Nm
557 writes a new set of defaults to its configuration file,
558 .Pa /etc/pw.conf .
559 When using the
560 .Fl D
561 option, you must not use either
562 .Fl n Ar name
563 or
564 .Fl u Ar uid
565 or an error will result.
566 Use of
567 .Fl D
568 changes the meaning of several command line switches in the
569 .Ar useradd
570 command.
571 These are:
572 .Bl -tag -width "-G grouplist"
573 .It Fl D
574 Set default values in
575 .Pa /etc/pw.conf
576 configuration file, or a different named configuration file if the
577 .Fl C Ar config
578 option is used.
579 .It Fl b Ar dir
580 Set the root directory in which user home directories are created.
581 The default value for this is
582 .Pa /home ,
583 but it may be set elsewhere as desired.
584 .It Fl e Ar days
585 Set the default account expiration period in days.
586 Unlike use without
587 .Fl D ,
588 the argument must be numeric, which specifies the number of days after creation when
589 the account is to expire.
590 A value of 0 suppresses automatic calculation of the expiry date.
591 .It Fl p Ar days
592 Set the default password expiration period in days.
593 .It Fl g Ar group
594 Set the default group for new users.
595 If a blank group is specified using
596 .Fl g Ar \&"" ,
597 then new users will be allocated their own private primary group
598 with the same name as their login name.
599 If a group is supplied, either its name or uid may be given as an argument.
600 .It Fl G Ar grouplist
601 Set the default groups in which new users are granted membership.
602 This is a separate set of groups from the primary group, and you should avoid
603 nominating the same group as both primary and extra groups.
604 In other words, these extra groups determine membership in groups
605 .Em other than
606 the primary group.
607 .Ar grouplist
608 is a comma-separated list of group names or ids, and are always
609 stored in
610 .Pa /etc/pw.conf
611 by their symbolic names.
612 .It Fl L Ar class
613 This option sets the default login class for new users.
614 .It Fl k Ar dir
615 Set the default
616 .Em skeleton
617 directory, from which prototype shell and other initialization files are copied when
618 .Nm
619 creates a user's home directory.
620 See description of
621 .Fl k
622 for naming conventions of these files.
623 .It Xo
624 .Fl u Ar min , Ns Ar max ,
625 .Fl i Ar min , Ns Ar max
626 .Xc
627 These options set the minimum and maximum user and group ids allocated for new accounts
628 and groups created by
629 .Nm .
630 The default values for each is 1000 minimum and 32000 maximum.
631 .Ar min
632 and
633 .Ar max
634 are both numbers, where max must be greater than min, and both must be between 0
635 and 32767.
636 In general, user and group ids less than 100 are reserved for use by the system,
637 and numbers greater than 32000 may also be reserved for special purposes (used by
638 some system daemons).
639 .It Fl w Ar method
640 The
641 .Fl w
642 option sets the default method used to set passwords for newly created user accounts.
643 .Ar method
644 is one of:
645 .Pp
646 .Bl -tag -width random -offset indent -compact
647 .It no
648 disable login on newly created accounts
649 .It yes
650 force the password to be the account name
651 .It none
652 force a blank password
653 .It random
654 generate a random password
655 .El
656 .Pp
657 The
658 .Ql \&random
659 or
660 .Ql \&no
661 methods are the most secure; in the former case,
662 .Nm
663 generates a password and prints it to stdout, which is suitable where you issue
664 users with passwords to access their accounts rather than having the user nominate
665 their own (possibly poorly chosen) password.
666 The
667 .Ql \&no
668 method requires that the superuser use
669 .Xr passwd 1
670 to render the account accessible with a password.
671 .It Fl y Ar path
672 This sets the pathname of the database used by
673 .Tn NIS
674 if you are not sharing
675 the information from
676 .Pa /etc/master.passwd
677 directly with
678 .Tn NIS .
679 You should only set this option for
680 .Tn NIS
681 servers.
682 .El
683 .Pp
684 The
685 .Ar userdel
686 command has only three valid options.
687 The
688 .Fl n Ar name
689 and
690 .Fl u Ar uid
691 options have already been covered above.
692 The additional option is:
693 .Bl -tag -width "-G grouplist"
694 .It Fl r
695 This tells
696 .Nm
697 to remove the user's home directory and all of its contents.
698 The
699 .Nm
700 utility errs on the side of caution when removing files from the system.
701 Firstly, it will not do so if the uid of the account being removed is also used by
702 another account on the system, and the 'home' directory in the password file is
703 a valid path that commences with the character
704 .Ql \&/ .
705 Secondly, it will only remove files and directories that are actually owned by
706 the user, or symbolic links owned by anyone under the user's home directory.
707 Finally, after deleting all contents owned by the user only empty directories
708 will be removed.
709 If any additional cleanup work is required, this is left to the administrator.
710 .El
711 .Pp
712 Mail spool files and crontabs are always removed when an account is deleted as these
713 are unconditionally attached to the user name.
714 Jobs queued for processing by
715 .Ar at
716 are also removed if the user's uid is unique and not also used by another account on the
717 system.
718 .Pp
719 The
720 .Ar usershow
721 command allows viewing of an account in one of two formats.
722 By default, the format is identical to the format used in
723 .Pa /etc/master.passwd
724 with the password field replaced with a
725 .Ql \&* .
726 If the
727 .Fl P
728 option is used, then
729 .Nm
730 outputs the account details in a more human readable form.
731 If the
732 .Fl 7
733 option is used, the account details are shown in v7 format.
734 The
735 .Fl a
736 option lists all users currently on file.
737 Using
738 .Fl F
739 forces
740 .Nm
741 to print the details of an account even if it does not exist.
742 .Pp
743 The command
744 .Ar usernext
745 returns the next available user and group ids separated by a colon.
746 This is normally of interest only to interactive scripts or front-ends
747 that use
748 .Nm .
749 .Sh GROUP OPTIONS
750 The
751 .Fl C
752 and
753 .Fl q
754 options (explained at the start of the previous section) are available
755 with the group manipulation commands.
756 Other common options to all group-related commands are:
757 .Bl -tag -width "-m newmembers"
758 .It Fl n Ar name
759 Specify the group name.
760 .It Fl g Ar gid
761 Specify the group numeric id.
762 .Pp
763 As with the account name and id fields, you will usually only need
764 to supply one of these, as the group name implies the uid and vice
765 versa.
766 You will only need to use both when setting a specific group id
767 against a new group or when changing the uid of an existing group.
768 .It Fl M Ar memberlist
769 This option provides an alternative way to add existing users to a
770 new group (in groupadd) or replace an existing membership list (in
771 groupmod).
772 .Ar memberlist
773 is a comma separated list of valid and existing user names or uids.
774 .It Fl m Ar newmembers
775 Similar to
776 .Fl M ,
777 this option allows the
778 .Em addition
779 of existing users to a group without replacing the existing list of
780 members.
781 Login names or user ids may be used, and duplicate users are
782 silently eliminated.
783 .It Fl d Ar oldmembers
784 Similar to
785 .Fl M ,
786 this option allows the
787 .Em deletion
788 of existing users from a group without replacing the existing list of
789 members.
790 Login names or user ids may be used, and duplicate users are
791 silently eliminated.
792 .El
793 .Pp
794 .Ar groupadd
795 also has a
796 .Fl o
797 option that allows allocation of an existing group id to a new group.
798 The default action is to reject an attempt to add a group, and this option overrides
799 the check for duplicate group ids.
800 There is rarely any need to duplicate a group id.
801 .Pp
802 The
803 .Ar groupmod
804 command adds one additional option:
805 .Pp
806 .Bl -tag -width "-m newmembers"
807 .It Fl l Ar name
808 This option allows changing of an existing group name to
809 .Ql \&name .
810 The new name must not already exist, and any attempt to duplicate an existing group
811 name will be rejected.
812 .El
813 .Pp
814 Options for
815 .Ar groupshow
816 are the same as for
817 .Ar usershow ,
818 with the
819 .Fl g Ar gid
820 replacing
821 .Fl u Ar uid
822 to specify the group id.
823 The
824 .Fl 7
825 option does not apply to the
826 .Ar groupshow
827 command.
828 .Pp
829 The command
830 .Ar groupnext
831 returns the next available group id on standard output.
832 .Sh USER LOCKING
833 The
834 .Nm
835 utility
836 supports a simple password locking mechanism for users; it works by
837 prepending the string
838 .Ql *LOCKED*
839 to the beginning of the password field in
840 .Pa master.passwd
841 to prevent successful authentication.
842 .Pp
843 The
844 .Ar lock
845 and
846 .Ar unlock
847 commands take a user name or uid of the account to lock or unlock,
848 respectively.
849 The
850 .Fl V ,
851 .Fl C ,
852 and
853 .Fl q
854 options as described above are accepted by these commands.
855 .Sh NOTES
856 For a summary of options available with each command, you can use
857 .Dl pw [command] help
858 For example,
859 .Dl pw useradd help
860 lists all available options for the useradd operation.
861 .Pp
862 The
863 .Nm
864 utility allows 8-bit characters in the passwd GECOS field (user's full name,
865 office, work and home phone number subfields), but disallows them in
866 user login and group names.
867 Use 8-bit characters with caution, as connection to the Internet will
868 require that your mail transport program supports 8BITMIME, and will
869 convert headers containing 8-bit characters to 7-bit quoted-printable
870 format.
871 .Xr sendmail 8
872 does support this.
873 Use of 8-bit characters in the GECOS field should be used in
874 conjunction with the user's default locale and character set
875 and should not be implemented without their use.
876 Using 8-bit characters may also affect other
877 programs that transmit the contents of the GECOS field over the
878 Internet, such as
879 .Xr fingerd 8 ,
880 and a small number of TCP/IP clients, such as IRC, where full names
881 specified in the passwd file may be used by default.
882 .Pp
883 The
884 .Nm
885 utility writes a log to the
886 .Pa /var/log/userlog
887 file when actions such as user or group additions or deletions occur.
888 The location of this logfile can be changed in
889 .Xr pw.conf 5 .
890 .Sh FILES
891 .Bl -tag -width /etc/master.passwd.new -compact
892 .It Pa /etc/master.passwd
893 The user database
894 .It Pa /etc/passwd
895 A Version 7 format password file
896 .It Pa /etc/login.conf
897 The user capabilities database
898 .It Pa /etc/group
899 The group database
900 .It Pa /etc/master.passwd.new
901 Temporary copy of the master password file
902 .It Pa /etc/passwd.new
903 Temporary copy of the Version 7 password file
904 .It Pa /etc/group.new
905 Temporary copy of the group file
906 .It Pa /etc/pw.conf
907 Pw default options file
908 .It Pa /var/log/userlog
909 User/group modification logfile
910 .El
911 .Sh EXIT STATUS
912 The
913 .Nm
914 utility returns EXIT_SUCCESS on successful operation, otherwise
915 .Nm
916 returns one of the
917 following exit codes defined by
918 .Xr sysexits 3
919 as follows:
920 .Bl -tag -width xxxx
921 .It EX_USAGE
922 .Bl -bullet -compact
923 .It
924 Command line syntax errors (invalid keyword, unknown option).
925 .El
926 .It EX_NOPERM
927 .Bl -bullet -compact
928 .It
929 Attempting to run one of the update modes as non-root.
930 .El
931 .It EX_OSERR
932 .Bl -bullet -compact
933 .It
934 Memory allocation error.
935 .It
936 Read error from password file descriptor.
937 .El
938 .It EX_DATAERR
939 .Bl -bullet -compact
940 .It
941 Bad or invalid data provided or missing on the command line or
942 via the password file descriptor.
943 .It
944 Attempted to remove, rename root account or change its uid.
945 .El
946 .It EX_OSFILE
947 .Bl -bullet -compact
948 .It
949 Skeleton directory is invalid or does not exist.
950 .It
951 Base home directory is invalid or does not exist.
952 .It
953 Invalid or non-existent shell specified.
954 .El
955 .It EX_NOUSER
956 .Bl -bullet -compact
957 .It
958 User, user id, group or group id specified does not exist.
959 .It
960 User or group recorded, added, or modified unexpectedly disappeared.
961 .El
962 .It EX_SOFTWARE
963 .Bl -bullet -compact
964 .It
965 No more group or user ids available within specified range.
966 .El
967 .It EX_IOERR
968 .Bl -bullet -compact
969 .It
970 Unable to rewrite configuration file.
971 .It
972 Error updating group or user database files.
973 .It
974 Update error for passwd or group database files.
975 .El
976 .It EX_CONFIG
977 .Bl -bullet -compact
978 .It
979 No base home directory configured.
980 .El
981 .El
982 .Sh SEE ALSO
983 .Xr chpass 1 ,
984 .Xr passwd 1 ,
985 .Xr umask 2 ,
986 .Xr group 5 ,
987 .Xr login.conf 5 ,
988 .Xr passwd 5 ,
989 .Xr pw.conf 5 ,
990 .Xr pwd_mkdb 8 ,
991 .Xr vipw 8
992 .Sh HISTORY
993 The
994 .Nm
995 utility was written to mimic many of the options used in the SYSV
996 .Em shadow
997 support suite, but is modified for passwd and group fields specific to
998 the
999 .Bx 4.4
1000 operating system, and combines all of the major elements
1001 into a single command.