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