xref: /freebsd/usr.sbin/pw/pw.8 (revision 5243e560f635e28d76a15f434d4ba7f87c1067d3)
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.\"
27feb04c7bSMateusz Piotrowski.Dd April 3, 2022
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
35a5b912ffSGlen Barber.Op Fl R Ar rootdir
365f12594aSDavid Nugent.Op Fl V Ar etcdir
375392b4fbSMateusz Piotrowski.Cm useradd
3839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name
39*5243e560SMateusz Piotrowski.Op Fl mNoPq
40d6f907dcSJoerg Wunsch.Op Fl C Ar config
41d6f907dcSJoerg Wunsch.Op Fl c Ar comment
42feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir
43feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate
44d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
4539245a7dSMateusz Piotrowski.Op Fl g Ar group
4639245a7dSMateusz Piotrowski.Op Fl H Ar fd
4739245a7dSMateusz Piotrowski.Op Fl h Ar fd
48feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
49d6f907dcSJoerg Wunsch.Op Fl L Ar class
5039245a7dSMateusz Piotrowski.Op Fl M Ar mode
51feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate
5239245a7dSMateusz Piotrowski.Op Fl s Ar shell
5339245a7dSMateusz Piotrowski.Op Fl u Ar uid
54feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
55*5243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
56e97407b4SRuslan Ermilov.Nm
57a5b912ffSGlen Barber.Op Fl R Ar rootdir
585f12594aSDavid Nugent.Op Fl V Ar etcdir
595392b4fbSMateusz Piotrowski.Cm useradd
60f1d684faSDavid Nugent.Fl D
61d6f907dcSJoerg Wunsch.Op Fl q
62feb04c7bSMateusz Piotrowski.Op Fl b Ar basehome
6339245a7dSMateusz Piotrowski.Op Fl C Ar config
64feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdays
65d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
6639245a7dSMateusz Piotrowski.Op Fl g Ar group
67feb04c7bSMateusz Piotrowski.Op Fl i Ar mingid , Ns Ar maxgid
68feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
69a0177bd5SMateusz Piotrowski.Op Fl M Ar mode
70feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdays
7139245a7dSMateusz Piotrowski.Op Fl s Ar shell
72feb04c7bSMateusz Piotrowski.Op Fl u Ar minuid , Ns Ar maxuid
73feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
74*5243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
75e97407b4SRuslan Ermilov.Nm
76a5b912ffSGlen Barber.Op Fl R Ar rootdir
775f12594aSDavid Nugent.Op Fl V Ar etcdir
785392b4fbSMateusz Piotrowski.Cm userdel
7939245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
80*5243e560SMateusz Piotrowski.Op Fl r
81*5243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
82e97407b4SRuslan Ermilov.Nm
83a5b912ffSGlen Barber.Op Fl R Ar rootdir
845f12594aSDavid Nugent.Op Fl V Ar etcdir
855392b4fbSMateusz Piotrowski.Cm usermod
865392b4fbSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Ar uid Oo Fl u Ar newuid Oc | Fl u Ar uid
87*5243e560SMateusz Piotrowski.Op Fl mNPq
88d6f907dcSJoerg Wunsch.Op Fl C Ar config
89d6f907dcSJoerg Wunsch.Op Fl c Ar comment
90feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir
91feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate
92feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
9339245a7dSMateusz Piotrowski.Op Fl G Ar grouplist
9439245a7dSMateusz Piotrowski.Op Fl g Ar group
9539245a7dSMateusz Piotrowski.Op Fl H Ar fd
9639245a7dSMateusz Piotrowski.Op Fl h Ar fd
97d6f907dcSJoerg Wunsch.Op Fl L Ar class
9839245a7dSMateusz Piotrowski.Op Fl l Ar newname
9939245a7dSMateusz Piotrowski.Op Fl M Ar mode
100feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate
10139245a7dSMateusz Piotrowski.Op Fl s Ar shell
102feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
103*5243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
104e97407b4SRuslan Ermilov.Nm
105a5b912ffSGlen Barber.Op Fl R Ar rootdir
1065f12594aSDavid Nugent.Op Fl V Ar etcdir
1075392b4fbSMateusz Piotrowski.Cm usershow
10839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
10939245a7dSMateusz Piotrowski.Op Fl 7aFP
110e97407b4SRuslan Ermilov.Nm
111a5b912ffSGlen Barber.Op Fl R Ar rootdir
1125f12594aSDavid Nugent.Op Fl V Ar etcdir
1135392b4fbSMateusz Piotrowski.Cm usernext
1143bfc59e8SBaptiste Daroussin.Op Fl q
11539245a7dSMateusz Piotrowski.Op Fl C Ar config
116e97407b4SRuslan Ermilov.Nm
117a5b912ffSGlen Barber.Op Fl R Ar rootdir
1185f12594aSDavid Nugent.Op Fl V Ar etcdir
1195392b4fbSMateusz Piotrowski.Cm groupadd
12039245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name
12139245a7dSMateusz Piotrowski.Op Fl oNPqY
122d6f907dcSJoerg Wunsch.Op Fl C Ar config
12339245a7dSMateusz Piotrowski.Op Fl g Ar gid
12439245a7dSMateusz Piotrowski.Op Fl H Ar fd
12539245a7dSMateusz Piotrowski.Op Fl h Ar fd
1269fd0dafcSJoerg Wunsch.Op Fl M Ar members
127e97407b4SRuslan Ermilov.Nm
128a5b912ffSGlen Barber.Op Fl R Ar rootdir
1295f12594aSDavid Nugent.Op Fl V Ar etcdir
1305392b4fbSMateusz Piotrowski.Cm groupdel
13139245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid
132f1d684faSDavid Nugent.Op Fl Y
133e97407b4SRuslan Ermilov.Nm
134a5b912ffSGlen Barber.Op Fl R Ar rootdir
1355f12594aSDavid Nugent.Op Fl V Ar etcdir
1365392b4fbSMateusz Piotrowski.Cm groupmod
1375392b4fbSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Ar gid Oo Fl g Ar newgid Oc | Fl g Ar gid
13839245a7dSMateusz Piotrowski.Op Fl NPqY
139d6f907dcSJoerg Wunsch.Op Fl C Ar config
14039245a7dSMateusz Piotrowski.Op Fl d Ar oldmembers
14139245a7dSMateusz Piotrowski.Op Fl H Ar fd
14239245a7dSMateusz Piotrowski.Op Fl h Ar fd
1431e4d5cf1SDevin Teske.Op Fl l Ar newname
1449fd0dafcSJoerg Wunsch.Op Fl M Ar members
1459fd0dafcSJoerg Wunsch.Op Fl m Ar newmembers
146e97407b4SRuslan Ermilov.Nm
147a5b912ffSGlen Barber.Op Fl R Ar rootdir
1485f12594aSDavid Nugent.Op Fl V Ar etcdir
1495392b4fbSMateusz Piotrowski.Cm groupshow
15039245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid
15139245a7dSMateusz Piotrowski.Op Fl aFP
152e97407b4SRuslan Ermilov.Nm
153a5b912ffSGlen Barber.Op Fl R Ar rootdir
1545f12594aSDavid Nugent.Op Fl V Ar etcdir
1555392b4fbSMateusz Piotrowski.Cm groupnext
1569fd0dafcSJoerg Wunsch.Op Fl C Ar config
1573bfc59e8SBaptiste Daroussin.Op Fl q
158e468afb4SDima Dorfman.Nm
159a5b912ffSGlen Barber.Op Fl R Ar rootdir
160e468afb4SDima Dorfman.Op Fl V Ar etcdir
1615392b4fbSMateusz Piotrowski.Cm lock
16239245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
163e468afb4SDima Dorfman.Op Fl q
16439245a7dSMateusz Piotrowski.Op Fl C Ar config
165e468afb4SDima Dorfman.Nm
166a5b912ffSGlen Barber.Op Fl R Ar rootdir
167e468afb4SDima Dorfman.Op Fl V Ar etcdir
1685392b4fbSMateusz Piotrowski.Cm unlock
16939245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
170e468afb4SDima Dorfman.Op Fl q
17139245a7dSMateusz Piotrowski.Op Fl C Ar config
172d6f907dcSJoerg Wunsch.Sh DESCRIPTION
173490d5836SPhilippe CharnierThe
174490d5836SPhilippe Charnier.Nm
175490d5836SPhilippe Charnierutility is a command-line based editor for the system
1761dcc6ec7SPhilippe Charnier.Ar user
177d6f907dcSJoerg Wunschand
1781dcc6ec7SPhilippe Charnier.Ar group
1793a7e7077SDaniel O'Callaghanfiles, allowing the superuser an easy to use and standardized way of adding,
180d6f907dcSJoerg Wunschmodifying and removing users and groups.
181d6f907dcSJoerg WunschNote that
1821dcc6ec7SPhilippe Charnier.Nm
183490d5836SPhilippe Charnieronly operates on the local user and group files.
184490d5836SPhilippe Charnier.Tn NIS
185490d5836SPhilippe Charnierusers and groups must be
186490d5836SPhilippe Charniermaintained on the
187490d5836SPhilippe Charnier.Tn NIS
188490d5836SPhilippe Charnierserver.
189490d5836SPhilippe CharnierThe
190490d5836SPhilippe Charnier.Nm
191490d5836SPhilippe Charnierutility handles updating the
19261e11ed9SMateusz Piotrowski.Xr passwd 5 ,
19361e11ed9SMateusz Piotrowski.Xr master.passwd 5 ,
19461e11ed9SMateusz Piotrowski.Xr group 5
195053375e8SMike Pritchardand the secure and insecure
196d6f907dcSJoerg Wunschpassword database files, and must be run as root.
197d6f907dcSJoerg Wunsch.Pp
198137db389SSteve PriceThe first one or two keywords provided to
199137db389SSteve Price.Nm
200137db389SSteve Priceon the command line provide the context for the remainder of the arguments.
201137db389SSteve PriceThe keywords
20261e11ed9SMateusz Piotrowski.Cm user
203d6f907dcSJoerg Wunschand
20461e11ed9SMateusz Piotrowski.Cm group
205137db389SSteve Pricemay be combined with
20661e11ed9SMateusz Piotrowski.Cm add ,
20761e11ed9SMateusz Piotrowski.Cm del ,
20861e11ed9SMateusz Piotrowski.Cm mod ,
20961e11ed9SMateusz Piotrowski.Cm show ,
2109fd0dafcSJoerg Wunschor
21161e11ed9SMateusz Piotrowski.Cm next
2124e86fcacSSheldon Hearnin any order.
2134e86fcacSSheldon Hearn(For example,
21461e11ed9SMateusz Piotrowski.Cm showuser ,
21561e11ed9SMateusz Piotrowski.Cm usershow ,
21661e11ed9SMateusz Piotrowski.Cm show user ,
217610a5778SRuslan Ermilovand
21861e11ed9SMateusz Piotrowski.Cm user show
219137db389SSteve Priceall mean the same thing.)
220137db389SSteve PriceThis flexibility is useful for interactive scripts calling
2211dcc6ec7SPhilippe Charnier.Nm
222137db389SSteve Pricefor user and group database manipulation.
2231e4d5cf1SDevin TeskeFollowing these keywords,
2241e4d5cf1SDevin Teskethe user or group name or numeric id may be optionally specified as an
2251e4d5cf1SDevin Teskealternative to using the
226d6f907dcSJoerg Wunsch.Fl n Ar name ,
227d6f907dcSJoerg Wunsch.Fl u Ar uid ,
228d6f907dcSJoerg Wunsch.Fl g Ar gid
2299fd0dafcSJoerg Wunschoptions.
230d6f907dcSJoerg Wunsch.Pp
231d5a3b1edSDima DorfmanThe following flags are common to most or all modes of operation:
2329fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
233a5b912ffSGlen Barber.It Fl R Ar rootdir
234a5b912ffSGlen BarberSpecifies an alternate root directory within which
235a5b912ffSGlen Barber.Nm
236a5b912ffSGlen Barberwill operate.
237a5b912ffSGlen BarberAny paths specified will be relative to
238a5b912ffSGlen Barber.Va rootdir .
2395f12594aSDavid Nugent.It Fl V Ar etcdir
2401e4d5cf1SDevin TeskeSet an alternate location for the password, group, and configuration files.
2411e4d5cf1SDevin TeskeCan be used to maintain a user/group database in an alternate location.
2425f12594aSDavid NugentIf this switch is specified, the system
2435f12594aSDavid Nugent.Pa /etc/pw.conf
2441e4d5cf1SDevin Teskewill not be sourced for default configuration data,
24561e11ed9SMateusz Piotrowskibut the file
24661e11ed9SMateusz Piotrowski.Pa pw.conf
24761e11ed9SMateusz Piotrowskiin the specified directory will be used instead
2481e4d5cf1SDevin Teske.Pq or none, if it does not exist .
2495f12594aSDavid NugentThe
2505f12594aSDavid Nugent.Fl C
2515f12594aSDavid Nugentflag may be used to override this behaviour.
2525f12594aSDavid NugentAs an exception to the general rule where options must follow the operation
2535f12594aSDavid Nugenttype, the
2545f12594aSDavid Nugent.Fl V
2554369c82dSBaptiste Daroussinflag must be used on the command line before the operation keyword.
256d6f907dcSJoerg Wunsch.It Fl C Ar config
257d6f907dcSJoerg WunschBy default,
2581dcc6ec7SPhilippe Charnier.Nm
259d6f907dcSJoerg Wunschreads the file
260d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
261137db389SSteve Priceto obtain policy information on how new user accounts and groups are to be created.
262137db389SSteve PriceThe
2639fd0dafcSJoerg Wunsch.Fl C
2649fd0dafcSJoerg Wunschoption specifies a different configuration file.
265137db389SSteve PriceWhile most of the contents of the configuration file may be overridden via
266137db389SSteve Pricecommand-line options, it may be more convenient to keep standard information in a
267137db389SSteve Priceconfiguration file.
268d6f907dcSJoerg Wunsch.It Fl q
269d6f907dcSJoerg WunschUse of this option causes
2701dcc6ec7SPhilippe Charnier.Nm
2711e4d5cf1SDevin Tesketo suppress error messages,
2721e4d5cf1SDevin Teskewhich may be useful in interactive environments where it
273d6f907dcSJoerg Wunschis preferable to interpret status codes returned by
2741dcc6ec7SPhilippe Charnier.Nm
275d6f907dcSJoerg Wunschrather than messing up a carefully formatted display.
2769fd0dafcSJoerg Wunsch.It Fl N
277137db389SSteve PriceThis option is available in
27861e11ed9SMateusz Piotrowski.Cm add
279137db389SSteve Priceand
28061e11ed9SMateusz Piotrowski.Cm modify
281137db389SSteve Priceoperations, and tells
2821dcc6ec7SPhilippe Charnier.Nm
283137db389SSteve Priceto output the result of the operation without updating the user or group
284137db389SSteve Pricedatabases.
2859fd0dafcSJoerg WunschYou may use the
2869fd0dafcSJoerg Wunsch.Fl P
2879fd0dafcSJoerg Wunschoption to switch between standard passwd and readable formats.
288f1d684faSDavid Nugent.It Fl Y
289f1d684faSDavid NugentUsing this option with any of the update modes causes
2901dcc6ec7SPhilippe Charnier.Nm
291f1d684faSDavid Nugentto run
292f1d684faSDavid Nugent.Xr make 1
293f1d684faSDavid Nugentafter changing to the directory
294f1d684faSDavid Nugent.Pa /var/yp .
295490d5836SPhilippe CharnierThis is intended to allow automatic updating of
296490d5836SPhilippe Charnier.Tn NIS
297490d5836SPhilippe Charnierdatabase files.
298490d5836SPhilippe CharnierIf separate passwd and group files are being used by
299490d5836SPhilippe Charnier.Tn NIS ,
300490d5836SPhilippe Charnierthen use the
301feb04c7bSMateusz Piotrowski.Fl y Ar nispasswd
302490d5836SPhilippe Charnieroption to specify the location of the
303490d5836SPhilippe Charnier.Tn NIS
304490d5836SPhilippe Charnierpasswd database so that
305137db389SSteve Price.Nm
306137db389SSteve Pricewill concurrently update it with the system password
307f1d684faSDavid Nugentdatabases.
308d6f907dcSJoerg Wunsch.El
309d6f907dcSJoerg Wunsch.Sh USER OPTIONS
310d6f907dcSJoerg WunschThe following options apply to the
31177fd0356SMateusz Piotrowski.Cm useradd
312d6f907dcSJoerg Wunschand
31377fd0356SMateusz Piotrowski.Cm usermod
314d6f907dcSJoerg Wunschcommands:
3159fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
3161e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name
3171e4d5cf1SDevin TeskeRequired unless
3181e4d5cf1SDevin Teske.Fl u Ar uid
3191e4d5cf1SDevin Teskeis given.
3201dcc6ec7SPhilippe CharnierSpecify the user/account name.
3211e4d5cf1SDevin TeskeIn the case of
32277fd0356SMateusz Piotrowski.Cm usermod
32377fd0356SMateusz Piotrowskican be a
32477fd0356SMateusz Piotrowski.Ar uid .
325d6f907dcSJoerg Wunsch.It Fl u Ar uid
3261e4d5cf1SDevin TeskeRequired if
3271e4d5cf1SDevin Teske.Ar name
3281e4d5cf1SDevin Teskeis not given.
3291dcc6ec7SPhilippe CharnierSpecify the user/account numeric id.
3301e4d5cf1SDevin TeskeIn the case of
33177fd0356SMateusz Piotrowski.Cm usermod
3321e4d5cf1SDevin Teskeif paired with
3331e4d5cf1SDevin Teske.Ar name ,
3341e4d5cf1SDevin Teskechanges the numeric id of the named user/account.
335d6f907dcSJoerg Wunsch.Pp
3361e4d5cf1SDevin TeskeUsually, only one of these options is required,
3371e4d5cf1SDevin Teskeas the account name will imply the uid, or vice versa.
3381e4d5cf1SDevin TeskeHowever, there are times when both are needed.
339d6f907dcSJoerg WunschFor example, when changing the uid of an existing user with
34077fd0356SMateusz Piotrowski.Cm usermod ,
3411e4d5cf1SDevin Teskeor overriding the default uid when creating a new account with
34277fd0356SMateusz Piotrowski.Cm useradd .
3431e4d5cf1SDevin TeskeTo automatically allocate the uid to a new user with
34477fd0356SMateusz Piotrowski.Cm useradd ,
3451e4d5cf1SDevin Teskethen do
346d6f907dcSJoerg Wunsch.Em not
347d6f907dcSJoerg Wunschuse the
34808657612SRuslan Ermilov.Fl u
3499fd0dafcSJoerg Wunschoption.
3501e4d5cf1SDevin TeskeEither the account or userid can also be provided immediately after the
35177fd0356SMateusz Piotrowski.Cm useradd ,
35277fd0356SMateusz Piotrowski.Cm userdel ,
35377fd0356SMateusz Piotrowski.Cm usermod ,
354137db389SSteve Priceor
35577fd0356SMateusz Piotrowski.Cm usershow
356137db389SSteve Pricekeywords on the command line without using the
35708657612SRuslan Ermilov.Fl n
358137db389SSteve Priceor
35908657612SRuslan Ermilov.Fl u
360137db389SSteve Priceoptions.
361d6f907dcSJoerg Wunsch.El
362d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
363d6f907dcSJoerg Wunsch.It Fl c Ar comment
3641e4d5cf1SDevin TeskeThis field sets the contents of the passwd GECOS field,
3651e4d5cf1SDevin Teskewhich normally contains up to four comma-separated fields containing the
3661e4d5cf1SDevin Teskeuser's full name, office or location,
367137db389SSteve Priceand work and home phone numbers.
368d6f907dcSJoerg WunschThese sub-fields are used by convention only, however, and are optional.
3691e4d5cf1SDevin TeskeIf this field is to contain spaces,
3701e4d5cf1SDevin Teskethe comment must be enclosed in double quotes
371d6f907dcSJoerg Wunsch.Ql \&" .
3721e4d5cf1SDevin TeskeAvoid using commas in this field as these are used as sub-field separators,
3731e4d5cf1SDevin Teskeand the colon
374d6f907dcSJoerg Wunsch.Ql \&:
375137db389SSteve Pricecharacter also cannot be used as this is the field separator for the passwd
376137db389SSteve Pricefile itself.
377feb04c7bSMateusz Piotrowski.It Fl d Ar homedir
378d6f907dcSJoerg WunschThis option sets the account's home directory.
3791e4d5cf1SDevin TeskeNormally,
3801e4d5cf1SDevin Teskethis is only used if the home directory is to be different from the
381137db389SSteve Pricedefault determined from
382137db389SSteve Price.Pa /etc/pw.conf
3831dcc6ec7SPhilippe Charnier- normally
3841dcc6ec7SPhilippe Charnier.Pa /home
385137db389SSteve Pricewith the account name as a subdirectory.
386feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdate
3871dcc6ec7SPhilippe CharnierSet the account's expiration date.
388d6f907dcSJoerg WunschFormat of the date is either a UNIX time in decimal, or a date in
389137db389SSteve Price.Ql dd-mmm-yy[yy]
3901e4d5cf1SDevin Teskeformat, where dd is the day,
3911e4d5cf1SDevin Teskemmm is the month, either in numeric or alphabetic format
3921dcc6ec7SPhilippe Charnier('Jan', 'Feb', etc) and year is either a two or four digit year.
393d6f907dcSJoerg WunschThis option also accepts a relative date in the form
394d6f907dcSJoerg Wunsch.Ql \&+n[mhdwoy]
395d6f907dcSJoerg Wunschwhere
396d6f907dcSJoerg Wunsch.Ql \&n
3971e4d5cf1SDevin Teskeis a decimal,
3981e4d5cf1SDevin Teskeoctal (leading 0) or hexadecimal (leading 0x) digit followed by the
399053375e8SMike Pritchardnumber of Minutes, Hours, Days, Weeks, Months or Years from the current date at
400137db389SSteve Pricewhich the expiration date is to be set.
401feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdate
4021dcc6ec7SPhilippe CharnierSet the account's password expiration date.
403137db389SSteve PriceThis field is similar to the account expiration date option, except that it
404d6f907dcSJoerg Wunschapplies to forced password changes.
405137db389SSteve PriceThis is set in the same manner as the
40608657612SRuslan Ermilov.Fl e
407137db389SSteve Priceoption.
408d6f907dcSJoerg Wunsch.It Fl g Ar group
4091dcc6ec7SPhilippe CharnierSet the account's primary group to the given group.
410d6f907dcSJoerg Wunsch.Ar group
411137db389SSteve Pricemay be defined by either its name or group number.
412d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
413579a636fSWarren BlockSet secondary group memberships for an account.
414d6f907dcSJoerg Wunsch.Ar grouplist
415579a636fSWarren Blockis a comma, space, or tab-separated list of group names or group numbers.
416579a636fSWarren BlockThe user is added to the groups specified in
417579a636fSWarren Block.Ar grouplist ,
418579a636fSWarren Blockand removed from all groups not specified.
419579a636fSWarren BlockThe current login session is not affected by group membership changes,
420579a636fSWarren Blockwhich only take effect when the user reconnects.
421579a636fSWarren BlockNote: do not add a user to their primary group with
422d6f907dcSJoerg Wunsch.Ar grouplist .
4239fd0dafcSJoerg Wunsch.It Fl L Ar class
4249fd0dafcSJoerg WunschThis option sets the login class for the user being created.
4259fd0dafcSJoerg WunschSee
4269fd0dafcSJoerg Wunsch.Xr login.conf 5
42716b4ad52SGiorgos Keramidasand
42816b4ad52SGiorgos Keramidas.Xr passwd 5
429137db389SSteve Pricefor more information on user login classes.
430d6f907dcSJoerg Wunsch.It Fl m
431d6f907dcSJoerg WunschThis option instructs
4321dcc6ec7SPhilippe Charnier.Nm
433d6f907dcSJoerg Wunschto attempt to create the user's home directory.
434d6f907dcSJoerg WunschWhile primarily useful when adding a new account with
43577fd0356SMateusz Piotrowski.Cm useradd ,
4361e4d5cf1SDevin Teskethis may also be of use when moving an existing user's home directory elsewhere
4371e4d5cf1SDevin Teskeon the file system.
438d6f907dcSJoerg WunschThe new home directory is populated with the contents of the
439d6f907dcSJoerg Wunsch.Ar skeleton
440d6f907dcSJoerg Wunschdirectory, which typically contains a set of shell configuration files that the
441053375e8SMike Pritcharduser may personalize to taste.
44231e224ddSTom RhodesFiles in this directory are usually named
443fd59f59aSTom Rhodes.Pa dot . Ns Aq Ar config
44431e224ddSTom Rhodeswhere the
445fd59f59aSTom Rhodes.Pa dot
44631e224ddSTom Rhodesprefix will be stripped.
447d6f907dcSJoerg WunschWhen
44808657612SRuslan Ermilov.Fl m
449d6f907dcSJoerg Wunschis used on an account with
45077fd0356SMateusz Piotrowski.Cm usermod ,
451137db389SSteve Priceexisting configuration files in the user's home directory are
452d6f907dcSJoerg Wunsch.Em not
453137db389SSteve Priceoverwritten from the skeleton files.
454d6f907dcSJoerg Wunsch.Pp
4551e4d5cf1SDevin TeskeWhen a user's home directory is created,
4561e4d5cf1SDevin Teskeit will by default be a subdirectory of the
457d6f907dcSJoerg Wunsch.Ar basehome
458137db389SSteve Pricedirectory as specified by the
45908657612SRuslan Ermilov.Fl b
46077fd0356SMateusz Piotrowskioption, bearing the name of the new account.
461137db389SSteve PriceThis can be overridden by the
46208657612SRuslan Ermilov.Fl d
463d6f907dcSJoerg Wunschoption on the command line, if desired.
464eebbeceeSLukas Ertl.It Fl M Ar mode
465eebbeceeSLukas ErtlCreate the user's home directory with the specified
46685204142SLukas Ertl.Ar mode ,
46785204142SLukas Ertlmodified by the current
46885204142SLukas Ertl.Xr umask 2 .
469eebbeceeSLukas ErtlIf omitted, it is derived from the parent process'
470eebbeceeSLukas Ertl.Xr umask 2 .
471eebbeceeSLukas ErtlThis option is only useful in combination with the
472eebbeceeSLukas Ertl.Fl m
473eebbeceeSLukas Ertlflag.
474feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir
4751dcc6ec7SPhilippe CharnierSet the
476d6f907dcSJoerg Wunsch.Ar skeleton
477137db389SSteve Pricedirectory, from which basic startup and configuration files are copied when
478d6f907dcSJoerg Wunschthe user's home directory is created.
479137db389SSteve PriceThis option only has meaning when used with the
48008657612SRuslan Ermilov.Fl d
481137db389SSteve Priceor
48208657612SRuslan Ermilov.Fl m
483137db389SSteve Priceflags.
484d6f907dcSJoerg Wunsch.It Fl s Ar shell
4851dcc6ec7SPhilippe CharnierSet or changes the user's login shell to
486d6f907dcSJoerg Wunsch.Ar shell .
487d6f907dcSJoerg WunschIf the path to the shell program is omitted,
4881dcc6ec7SPhilippe Charnier.Nm
489d6f907dcSJoerg Wunschsearches the
490d6f907dcSJoerg Wunsch.Ar shellpath
491d6f907dcSJoerg Wunschspecified in
492d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
493d6f907dcSJoerg Wunschand fills it in as appropriate.
494d6f907dcSJoerg WunschNote that unless you have a specific reason to do so, you should avoid
495d6f907dcSJoerg Wunschspecifying the path - this will allow
4961dcc6ec7SPhilippe Charnier.Nm
497d6f907dcSJoerg Wunschto validate that the program exists and is executable.
498d6f907dcSJoerg WunschSpecifying a full path (or supplying a blank "" shell) avoids this check
499d6f907dcSJoerg Wunschand allows for such entries as
5001dcc6ec7SPhilippe Charnier.Pa /nonexistent
501d6f907dcSJoerg Wunschthat should be set for accounts not intended for interactive login.
502d6f907dcSJoerg Wunsch.It Fl h Ar fd
503d6f907dcSJoerg WunschThis option provides a special interface by which interactive scripts can
504d6f907dcSJoerg Wunschset an account password using
505e97407b4SRuslan Ermilov.Nm .
506137db389SSteve PriceBecause the command line and environment are fundamentally insecure mechanisms
507d6f907dcSJoerg Wunschby which programs can accept information,
5081dcc6ec7SPhilippe Charnier.Nm
509d6f907dcSJoerg Wunschwill only allow setting of account and group passwords via a file descriptor
510d6f907dcSJoerg Wunsch(usually a pipe between an interactive script and the program).
511d6f907dcSJoerg Wunsch.Ar sh ,
512d6f907dcSJoerg Wunsch.Ar bash ,
513d6f907dcSJoerg Wunsch.Ar ksh
514d6f907dcSJoerg Wunschand
515d6f907dcSJoerg Wunsch.Ar perl
516137db389SSteve Priceall possess mechanisms by which this can be done.
517d6f907dcSJoerg WunschAlternatively,
518325970a9SPhilippe Charnier.Nm
519d6f907dcSJoerg Wunschwill prompt for the user's password if
52008657612SRuslan Ermilov.Fl h Ar 0
521d6f907dcSJoerg Wunschis given, nominating
522d6f907dcSJoerg Wunsch.Em stdin
523d6f907dcSJoerg Wunschas the file descriptor on which to read the password.
524137db389SSteve PriceNote that this password will be read only once and is intended
525137db389SSteve Pricefor use by a script rather than for interactive use.
526d6f907dcSJoerg WunschIf you wish to have new password confirmation along the lines of
527d6f907dcSJoerg Wunsch.Xr passwd 1 ,
528137db389SSteve Pricethis must be implemented as part of an interactive script that calls
529e97407b4SRuslan Ermilov.Nm .
530d6f907dcSJoerg Wunsch.Pp
531d6f907dcSJoerg WunschIf a value of
532d6f907dcSJoerg Wunsch.Ql \&-
533d6f907dcSJoerg Wunschis given as the argument
534d6f907dcSJoerg Wunsch.Ar fd ,
535d6f907dcSJoerg Wunschthen the password will be set to
536d6f907dcSJoerg Wunsch.Ql \&* ,
537137db389SSteve Pricerendering the account inaccessible via password-based login.
53887d6b5caSIan Dowse.It Fl H Ar fd
53987d6b5caSIan DowseRead an encrypted password string from the specified file descriptor.
54087d6b5caSIan DowseThis is like
54187d6b5caSIan Dowse.Fl h ,
54287d6b5caSIan Dowsebut the password should be supplied already encrypted in a form
54387d6b5caSIan Dowsesuitable for writing directly to the password database.
544d6f907dcSJoerg Wunsch.El
545d6f907dcSJoerg Wunsch.Pp
546d6f907dcSJoerg WunschIt is possible to use
54777fd0356SMateusz Piotrowski.Cm useradd
548d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id.
549d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the
55008657612SRuslan Ermilov.Fl o
5519fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of
5529fd0dafcSJoerg Wunschthe user id.
5539fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under
5549fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home
5559fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same
5569fd0dafcSJoerg Wunschpermissions for access to the user's files in each account.
557d6f907dcSJoerg Wunsch.Pp
558d6f907dcSJoerg WunschThe
55977fd0356SMateusz Piotrowski.Cm useradd
560d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the
56108657612SRuslan Ermilov.Fl D
5629fd0dafcSJoerg Wunschoption.
563d6f907dcSJoerg WunschInstead of adding a new user,
5641dcc6ec7SPhilippe Charnier.Nm
565d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file,
566d6f907dcSJoerg Wunsch.Pa /etc/pw.conf .
567d6f907dcSJoerg WunschWhen using the
56808657612SRuslan Ermilov.Fl D
5699fd0dafcSJoerg Wunschoption, you must not use either
57008657612SRuslan Ermilov.Fl n Ar name
571d6f907dcSJoerg Wunschor
57208657612SRuslan Ermilov.Fl u Ar uid
573d6f907dcSJoerg Wunschor an error will result.
574d6f907dcSJoerg WunschUse of
57508657612SRuslan Ermilov.Fl D
5769fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the
577d6f907dcSJoerg Wunsch.Ar useradd
578d6f907dcSJoerg Wunschcommand.
579d6f907dcSJoerg WunschThese are:
580d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
581d6f907dcSJoerg Wunsch.It Fl D
582d6f907dcSJoerg WunschSet default values in
583d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
584d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the
58508657612SRuslan Ermilov.Fl C Ar config
5869fd0dafcSJoerg Wunschoption is used.
587feb04c7bSMateusz Piotrowski.It Fl b Ar basehome
5881dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created.
589d6f907dcSJoerg WunschThe default value for this is
5901dcc6ec7SPhilippe Charnier.Pa /home ,
591d6f907dcSJoerg Wunschbut it may be set elsewhere as desired.
592feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdays
5931dcc6ec7SPhilippe CharnierSet the default account expiration period in days.
5941e4d5cf1SDevin TeskeWhen
5951e4d5cf1SDevin Teske.Fl D
5961e4d5cf1SDevin Teskeis used, the
597feb04c7bSMateusz Piotrowski.Ar accexpdays
5981e4d5cf1SDevin Teskeargument is interpreted differently.
5991e4d5cf1SDevin TeskeIt must be numeric and represents the number of days after creation
6001e4d5cf1SDevin Teskethat the account expires.
601d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date.
602feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdays
6031dcc6ec7SPhilippe CharnierSet the default password expiration period in days.
604d30f122fSEugene GrosbeinWhen
605d30f122fSEugene Grosbein.Fl D
606d30f122fSEugene Grosbeinis used, the
607feb04c7bSMateusz Piotrowski.Ar passexpdays
608d30f122fSEugene Grosbeinargument is interpreted differently.
609d30f122fSEugene GrosbeinIt must be numeric and represents the number of days after creation
610d30f122fSEugene Grosbeinthat the account expires.
611d30f122fSEugene GrosbeinA value of 0 suppresses automatic calculation of the expiry date.
612d6f907dcSJoerg Wunsch.It Fl g Ar group
6131dcc6ec7SPhilippe CharnierSet the default group for new users.
614d6f907dcSJoerg WunschIf a blank group is specified using
61508657612SRuslan Ermilov.Fl g Ar \&"" ,
616137db389SSteve Pricethen new users will be allocated their own private primary group
617137db389SSteve Pricewith the same name as their login name.
618d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument.
619d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
620137db389SSteve PriceSet the default groups in which new users are granted membership.
6211e4d5cf1SDevin TeskeThis is a separate set of groups from the primary group.
6221e4d5cf1SDevin TeskeAvoid nominating the same group as both primary and extra groups.
623d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups
624d6f907dcSJoerg Wunsch.Em other than
625d6f907dcSJoerg Wunschthe primary group.
626d6f907dcSJoerg Wunsch.Ar grouplist
627137db389SSteve Priceis a comma-separated list of group names or ids, and are always
628d6f907dcSJoerg Wunschstored in
629d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
630d6f907dcSJoerg Wunschby their symbolic names.
6319fd0dafcSJoerg Wunsch.It Fl L Ar class
6329fd0dafcSJoerg WunschThis option sets the default login class for new users.
633feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir
6341dcc6ec7SPhilippe CharnierSet the default
635d6f907dcSJoerg Wunsch.Em skeleton
6361e4d5cf1SDevin Teskedirectory,
6371e4d5cf1SDevin Teskefrom which prototype shell and other initialization files are copied when
6381dcc6ec7SPhilippe Charnier.Nm
639d6f907dcSJoerg Wunschcreates a user's home directory.
64031e224ddSTom RhodesSee description of
64131e224ddSTom Rhodes.Fl k
64231e224ddSTom Rhodesfor naming conventions of these files.
643610a5778SRuslan Ermilov.It Xo
644feb04c7bSMateusz Piotrowski.Fl u Ar minuid Ns Cm \&, Ns Ar maxuid ,
645feb04c7bSMateusz Piotrowski.Fl i Ar mingid Ns Cm \&, Ns Ar maxgid
646610a5778SRuslan Ermilov.Xc
6471e4d5cf1SDevin TeskeSet the minimum and maximum user and group ids allocated for new
6481e4d5cf1SDevin Teskeaccounts and groups created by
649e97407b4SRuslan Ermilov.Nm .
650d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum.
651feb04c7bSMateusz Piotrowski.Ar minuid
652d6f907dcSJoerg Wunschand
653feb04c7bSMateusz Piotrowski.Ar maxuid
6541e4d5cf1SDevin Teskeare both numbers, where max must be greater than min,
655feb04c7bSMateusz Piotrowskiand both must be between 0 and 32767
656feb04c7bSMateusz Piotrowski.Po the same applies to
657feb04c7bSMateusz Piotrowski.Ar mingid
658feb04c7bSMateusz Piotrowskiand
659feb04c7bSMateusz Piotrowski.Ar maxgid
660feb04c7bSMateusz Piotrowski.Pc .
6611e4d5cf1SDevin TeskeIn general,
6621e4d5cf1SDevin Teskeuser and group ids less than 100 are reserved for use by the system,
6631e4d5cf1SDevin Teskeand numbers greater than 32000 may also be reserved for special purposes
6641e4d5cf1SDevin Teske.Pq used by some system daemons .
665feb04c7bSMateusz Piotrowski.It Fl w Ar passmethod
666d6f907dcSJoerg WunschThe
66708657612SRuslan Ermilov.Fl w
6681e4d5cf1SDevin Teskeoption selects the default method used to set passwords for newly created user
6691e4d5cf1SDevin Teskeaccounts.
670feb04c7bSMateusz Piotrowski.Ar passmethod
671d6f907dcSJoerg Wunschis one of:
672d6f907dcSJoerg Wunsch.Pp
673d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact
67477fd0356SMateusz Piotrowski.It Cm no
6751dcc6ec7SPhilippe Charnierdisable login on newly created accounts
67677fd0356SMateusz Piotrowski.It Cm yes
6771dcc6ec7SPhilippe Charnierforce the password to be the account name
67877fd0356SMateusz Piotrowski.It Cm none
6791dcc6ec7SPhilippe Charnierforce a blank password
68077fd0356SMateusz Piotrowski.It Cm random
6811dcc6ec7SPhilippe Charniergenerate a random password
682d6f907dcSJoerg Wunsch.El
683d6f907dcSJoerg Wunsch.Pp
684d6f907dcSJoerg WunschThe
68577fd0356SMateusz Piotrowski.Cm random
686d6f907dcSJoerg Wunschor
68777fd0356SMateusz Piotrowski.Cm no
688d6f907dcSJoerg Wunschmethods are the most secure; in the former case,
6891dcc6ec7SPhilippe Charnier.Nm
6901e4d5cf1SDevin Teskegenerates a password and prints it to stdout,
6911e4d5cf1SDevin Teskewhich is suitable when users are issued passwords rather than being allowed
6921e4d5cf1SDevin Tesketo select their own
6931e4d5cf1SDevin Teske.Pq possibly poorly chosen
6941e4d5cf1SDevin Teskepassword.
695d6f907dcSJoerg WunschThe
69677fd0356SMateusz Piotrowski.Cm no
697d6f907dcSJoerg Wunschmethod requires that the superuser use
698d6f907dcSJoerg Wunsch.Xr passwd 1
699d6f907dcSJoerg Wunschto render the account accessible with a password.
700f1d684faSDavid Nugent.It Fl y Ar path
701490d5836SPhilippe CharnierThis sets the pathname of the database used by
702490d5836SPhilippe Charnier.Tn NIS
703490d5836SPhilippe Charnierif you are not sharing
704f1d684faSDavid Nugentthe information from
705f1d684faSDavid Nugent.Pa /etc/master.passwd
706490d5836SPhilippe Charnierdirectly with
707490d5836SPhilippe Charnier.Tn NIS .
708490d5836SPhilippe CharnierYou should only set this option for
709490d5836SPhilippe Charnier.Tn NIS
710490d5836SPhilippe Charnierservers.
711d6f907dcSJoerg Wunsch.El
712d6f907dcSJoerg Wunsch.Pp
713d6f907dcSJoerg WunschThe
71477fd0356SMateusz Piotrowski.Cm userdel
7151e4d5cf1SDevin Teskecommand has three distinct options.
716f2e366a1SSheldon HearnThe
71708657612SRuslan Ermilov.Fl n Ar name
718d6f907dcSJoerg Wunschand
71908657612SRuslan Ermilov.Fl u Ar uid
7209fd0dafcSJoerg Wunschoptions have already been covered above.
7219fd0dafcSJoerg WunschThe additional option is:
7229fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
723d6f907dcSJoerg Wunsch.It Fl r
724d6f907dcSJoerg WunschThis tells
7251dcc6ec7SPhilippe Charnier.Nm
726d6f907dcSJoerg Wunschto remove the user's home directory and all of its contents.
727490d5836SPhilippe CharnierThe
728490d5836SPhilippe Charnier.Nm
729490d5836SPhilippe Charnierutility errs on the side of caution when removing files from the system.
7301e4d5cf1SDevin TeskeFirstly,
7311e4d5cf1SDevin Teskeit will not do so if the uid of the account being removed is also used by
73277fd0356SMateusz Piotrowskianother account on the system, and the
73377fd0356SMateusz Piotrowski.Dq home
73477fd0356SMateusz Piotrowskidirectory in the password file is
735d6f907dcSJoerg Wunscha valid path that commences with the character
736d6f907dcSJoerg Wunsch.Ql \&/ .
737d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by
738d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory.
739d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories
740d6f907dcSJoerg Wunschwill be removed.
741053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator.
742d6f907dcSJoerg Wunsch.El
743d6f907dcSJoerg Wunsch.Pp
74477fd0356SMateusz PiotrowskiMail spool files and
74577fd0356SMateusz Piotrowski.Xr crontab 5
74677fd0356SMateusz Piotrowskifiles are always removed when an account is deleted as
7471e4d5cf1SDevin Teskethese are unconditionally attached to the user name.
748d6f907dcSJoerg WunschJobs queued for processing by
74977fd0356SMateusz Piotrowski.Xr at 1
7501e4d5cf1SDevin Teskeare also removed if the user's uid is unique and not also used by another
7511e4d5cf1SDevin Teskeaccount on the system.
752d6f907dcSJoerg Wunsch.Pp
753d6f907dcSJoerg WunschThe
75477fd0356SMateusz Piotrowski.Cm usermod
75519e1bf29SEitan Adlercommand adds one additional option:
75619e1bf29SEitan Adler.Bl -tag -width "-G grouplist"
7571e4d5cf1SDevin Teske.It Fl l Ar newname
75819e1bf29SEitan AdlerThis option allows changing of an existing account name to
75977fd0356SMateusz Piotrowski.Ar newname .
76019e1bf29SEitan AdlerThe new name must not already exist, and any attempt to duplicate an
76119e1bf29SEitan Adlerexisting account name will be rejected.
76219e1bf29SEitan Adler.El
76319e1bf29SEitan Adler.Pp
76419e1bf29SEitan AdlerThe
76577fd0356SMateusz Piotrowski.Cm usershow
766d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats.
767d6f907dcSJoerg WunschBy default, the format is identical to the format used in
768d6f907dcSJoerg Wunsch.Pa /etc/master.passwd
769d6f907dcSJoerg Wunschwith the password field replaced with a
770d6f907dcSJoerg Wunsch.Ql \&* .
771d6f907dcSJoerg WunschIf the
77208657612SRuslan Ermilov.Fl P
7739fd0dafcSJoerg Wunschoption is used, then
7741dcc6ec7SPhilippe Charnier.Nm
775d6f907dcSJoerg Wunschoutputs the account details in a more human readable form.
7764731d076SDima DorfmanIf the
7774731d076SDima Dorfman.Fl 7
7784731d076SDima Dorfmanoption is used, the account details are shown in v7 format.
779d6f907dcSJoerg WunschThe
78008657612SRuslan Ermilov.Fl a
7819fd0dafcSJoerg Wunschoption lists all users currently on file.
782466c257cSDima DorfmanUsing
783466c257cSDima Dorfman.Fl F
784466c257cSDima Dorfmanforces
785466c257cSDima Dorfman.Nm
786466c257cSDima Dorfmanto print the details of an account even if it does not exist.
7879fd0dafcSJoerg Wunsch.Pp
7889fd0dafcSJoerg WunschThe command
78977fd0356SMateusz Piotrowski.Cm usernext
7909fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon.
7919fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends
7929fd0dafcSJoerg Wunschthat use
793e97407b4SRuslan Ermilov.Nm .
794d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS
795d6f907dcSJoerg WunschThe
79608657612SRuslan Ermilov.Fl C
797d6f907dcSJoerg Wunschand
79808657612SRuslan Ermilov.Fl q
7999fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available
8009fd0dafcSJoerg Wunschwith the group manipulation commands.
801d6f907dcSJoerg WunschOther common options to all group-related commands are:
8029fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8031e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name
8041e4d5cf1SDevin TeskeRequired unless
8051e4d5cf1SDevin Teske.Fl g Ar gid
8061e4d5cf1SDevin Teskeis given.
8071dcc6ec7SPhilippe CharnierSpecify the group name.
8081e4d5cf1SDevin TeskeIn the case of
80977fd0356SMateusz Piotrowski.Cm groupmod
8101e4d5cf1SDevin Teskecan be a gid.
811d6f907dcSJoerg Wunsch.It Fl g Ar gid
8121e4d5cf1SDevin TeskeRequired if
8131e4d5cf1SDevin Teske.Ar name
8141e4d5cf1SDevin Teskeis not given.
8151dcc6ec7SPhilippe CharnierSpecify the group numeric id.
8161e4d5cf1SDevin TeskeIn the case of
81777fd0356SMateusz Piotrowski.Cm groupmod
8181e4d5cf1SDevin Teskeif paired with
8191e4d5cf1SDevin Teske.Ar name ,
8201e4d5cf1SDevin Teskechanges the numeric id of the named group.
821d6f907dcSJoerg Wunsch.Pp
8229fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need
8239fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice
8249fd0dafcSJoerg Wunschversa.
8259fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id
8269fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group.
8277ecd7a42SJoseph Koshy.It Fl M Ar memberlist
8289fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a
82977fd0356SMateusz Piotrowskinew group
83077fd0356SMateusz Piotrowski.Pq in Cm groupadd
83177fd0356SMateusz Piotrowskior replace an existing membership list
83277fd0356SMateusz Piotrowski.Pq in Cm groupmod .
8339fd0dafcSJoerg Wunsch.Ar memberlist
8349fd0dafcSJoerg Wunschis a comma separated list of valid and existing user names or uids.
8359fd0dafcSJoerg Wunsch.It Fl m Ar newmembers
8369fd0dafcSJoerg WunschSimilar to
83708657612SRuslan Ermilov.Fl M ,
8389fd0dafcSJoerg Wunschthis option allows the
8399fd0dafcSJoerg Wunsch.Em addition
840137db389SSteve Priceof existing users to a group without replacing the existing list of
8419fd0dafcSJoerg Wunschmembers.
842137db389SSteve PriceLogin names or user ids may be used, and duplicate users are
843137db389SSteve Pricesilently eliminated.
844bc991a6dSSean Farley.It Fl d Ar oldmembers
845bc991a6dSSean FarleySimilar to
846bc991a6dSSean Farley.Fl M ,
847bc991a6dSSean Farleythis option allows the
848bc991a6dSSean Farley.Em deletion
849bc991a6dSSean Farleyof existing users from a group without replacing the existing list of
850bc991a6dSSean Farleymembers.
851bc991a6dSSean FarleyLogin names or user ids may be used, and duplicate users are
852bc991a6dSSean Farleysilently eliminated.
853d6f907dcSJoerg Wunsch.El
854d6f907dcSJoerg Wunsch.Pp
85577fd0356SMateusz Piotrowski.Cm groupadd
856d6f907dcSJoerg Wunschalso has a
85708657612SRuslan Ermilov.Fl o
858137db389SSteve Priceoption that allows allocation of an existing group id to a new group.
8591e4d5cf1SDevin TeskeThe default action is to reject an attempt to add a group,
8601e4d5cf1SDevin Teskeand this option overrides the check for duplicate group ids.
861d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id.
862d6f907dcSJoerg Wunsch.Pp
863d6f907dcSJoerg WunschThe
86477fd0356SMateusz Piotrowski.Cm groupmod
865137db389SSteve Pricecommand adds one additional option:
8669fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8671e4d5cf1SDevin Teske.It Fl l Ar newname
868d6f907dcSJoerg WunschThis option allows changing of an existing group name to
86977fd0356SMateusz Piotrowski.Ar newname .
8701e4d5cf1SDevin TeskeThe new name must not already exist,
8711e4d5cf1SDevin Teskeand any attempt to duplicate an existing group
872d6f907dcSJoerg Wunschname will be rejected.
873d6f907dcSJoerg Wunsch.El
874d6f907dcSJoerg Wunsch.Pp
875d6f907dcSJoerg WunschOptions for
87677fd0356SMateusz Piotrowski.Cm groupshow
877d6f907dcSJoerg Wunschare the same as for
87877fd0356SMateusz Piotrowski.Cm usershow ,
879d6f907dcSJoerg Wunschwith the
88008657612SRuslan Ermilov.Fl g Ar gid
881d6f907dcSJoerg Wunschreplacing
88208657612SRuslan Ermilov.Fl u Ar uid
883d6f907dcSJoerg Wunschto specify the group id.
8844731d076SDima DorfmanThe
8854731d076SDima Dorfman.Fl 7
8864731d076SDima Dorfmanoption does not apply to the
88777fd0356SMateusz Piotrowski.Cm groupshow
8884731d076SDima Dorfmancommand.
889d6f907dcSJoerg Wunsch.Pp
8909fd0dafcSJoerg WunschThe command
89177fd0356SMateusz Piotrowski.Cm groupnext
8929fd0dafcSJoerg Wunschreturns the next available group id on standard output.
893e468afb4SDima Dorfman.Sh USER LOCKING
894490d5836SPhilippe CharnierThe
895490d5836SPhilippe Charnier.Nm
896490d5836SPhilippe Charnierutility
897e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by
898e468afb4SDima Dorfmanprepending the string
899e468afb4SDima Dorfman.Ql *LOCKED*
900e468afb4SDima Dorfmanto the beginning of the password field in
90177fd0356SMateusz Piotrowski.Xr master.passwd 5
902e468afb4SDima Dorfmanto prevent successful authentication.
903e468afb4SDima Dorfman.Pp
904e468afb4SDima DorfmanThe
90577fd0356SMateusz Piotrowski.Cm lock
906e468afb4SDima Dorfmanand
90777fd0356SMateusz Piotrowski.Cm unlock
908e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock,
90907bfccd7SRuslan Ermilovrespectively.
91007bfccd7SRuslan ErmilovThe
91108657612SRuslan Ermilov.Fl V ,
91208657612SRuslan Ermilov.Fl C ,
913e468afb4SDima Dorfmanand
91408657612SRuslan Ermilov.Fl q
915e468afb4SDima Dorfmanoptions as described above are accepted by these commands.
91659a3c79dSRuslan Ermilov.Sh NOTES
91759a3c79dSRuslan ErmilovFor a summary of options available with each command, you can use
91859a3c79dSRuslan Ermilov.Dl pw [command] help
91959a3c79dSRuslan ErmilovFor example,
92059a3c79dSRuslan Ermilov.Dl pw useradd help
92177fd0356SMateusz Piotrowskilists all available options for the
92277fd0356SMateusz Piotrowski.Cm useradd
92377fd0356SMateusz Piotrowskioperation.
92459a3c79dSRuslan Ermilov.Pp
92559a3c79dSRuslan ErmilovThe
92659a3c79dSRuslan Ermilov.Nm
92759a3c79dSRuslan Ermilovutility allows 8-bit characters in the passwd GECOS field (user's full name,
92859a3c79dSRuslan Ermilovoffice, work and home phone number subfields), but disallows them in
92959a3c79dSRuslan Ermilovuser login and group names.
93059a3c79dSRuslan ErmilovUse 8-bit characters with caution, as connection to the Internet will
93159a3c79dSRuslan Ermilovrequire that your mail transport program supports 8BITMIME, and will
93259a3c79dSRuslan Ermilovconvert headers containing 8-bit characters to 7-bit quoted-printable
93359a3c79dSRuslan Ermilovformat.
93459a3c79dSRuslan Ermilov.Xr sendmail 8
93559a3c79dSRuslan Ermilovdoes support this.
93659a3c79dSRuslan ErmilovUse of 8-bit characters in the GECOS field should be used in
93759a3c79dSRuslan Ermilovconjunction with the user's default locale and character set
93859a3c79dSRuslan Ermilovand should not be implemented without their use.
93959a3c79dSRuslan ErmilovUsing 8-bit characters may also affect other
94059a3c79dSRuslan Ermilovprograms that transmit the contents of the GECOS field over the
94159a3c79dSRuslan ErmilovInternet, such as
94259a3c79dSRuslan Ermilov.Xr fingerd 8 ,
94359a3c79dSRuslan Ermilovand a small number of TCP/IP clients, such as IRC, where full names
94459a3c79dSRuslan Ermilovspecified in the passwd file may be used by default.
94559a3c79dSRuslan Ermilov.Pp
94659a3c79dSRuslan ErmilovThe
94759a3c79dSRuslan Ermilov.Nm
94859a3c79dSRuslan Ermilovutility writes a log to the
94959a3c79dSRuslan Ermilov.Pa /var/log/userlog
95059a3c79dSRuslan Ermilovfile when actions such as user or group additions or deletions occur.
95159a3c79dSRuslan ErmilovThe location of this logfile can be changed in
95259a3c79dSRuslan Ermilov.Xr pw.conf 5 .
95359a3c79dSRuslan Ermilov.Sh FILES
95459a3c79dSRuslan Ermilov.Bl -tag -width /etc/master.passwd.new -compact
95559a3c79dSRuslan Ermilov.It Pa /etc/master.passwd
95659a3c79dSRuslan ErmilovThe user database
95759a3c79dSRuslan Ermilov.It Pa /etc/passwd
95859a3c79dSRuslan ErmilovA Version 7 format password file
95959a3c79dSRuslan Ermilov.It Pa /etc/login.conf
96059a3c79dSRuslan ErmilovThe user capabilities database
96159a3c79dSRuslan Ermilov.It Pa /etc/group
96259a3c79dSRuslan ErmilovThe group database
96359a3c79dSRuslan Ermilov.It Pa /etc/pw.conf
96459a3c79dSRuslan ErmilovPw default options file
96559a3c79dSRuslan Ermilov.It Pa /var/log/userlog
96659a3c79dSRuslan ErmilovUser/group modification logfile
96759a3c79dSRuslan Ermilov.El
9689b8a603eSWarren Block.Sh EXAMPLES
9699b8a603eSWarren BlockAdd new user Glurmo Smith (gsmith).
9709b8a603eSWarren BlockA gsmith login group is created if not already present.
9719b8a603eSWarren BlockThe login shell is set to
9729b8a603eSWarren Block.Xr csh 1 .
9739b8a603eSWarren BlockA new home directory at
9749b8a603eSWarren Block.Pa /home/gsmith
9759b8a603eSWarren Blockis created if it does not already exist.
9769b8a603eSWarren BlockFinally, a random password is generated and displayed:
9779b8a603eSWarren Block.Bd -literal -offset indent
9789b8a603eSWarren Blockpw useradd -n gsmith -c "Glurmo Smith" -s /bin/csh -m -w random
9799b8a603eSWarren Block.Ed
980bb00e549SWarren Block.Pp
981bb00e549SWarren BlockDelete the gsmith user and their home directory, including contents.
982bb00e549SWarren Block.Bd -literal -offset indent
983bb00e549SWarren Blockpw userdel -n gsmith -r
984bb00e549SWarren Block.Ed
98560c81cf1SBenedict Reuschling.Pp
98660c81cf1SBenedict ReuschlingAdd the existing user jsmith to the wheel group,
98760c81cf1SBenedict Reuschlingin addition to the other groups jsmith is already a member of.
98860c81cf1SBenedict Reuschling.Bd -literal -offset indent
98960c81cf1SBenedict Reuschlingpw groupmod wheel -m jsmith
99060c81cf1SBenedict Reuschling.Ed
991a866e170SRuslan Ermilov.Sh EXIT STATUS
992490d5836SPhilippe CharnierThe
993490d5836SPhilippe Charnier.Nm
994490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise
995137db389SSteve Price.Nm
996137db389SSteve Pricereturns one of the
9979fd0dafcSJoerg Wunschfollowing exit codes defined by
9989fd0dafcSJoerg Wunsch.Xr sysexits 3
9999fd0dafcSJoerg Wunschas follows:
10009fd0dafcSJoerg Wunsch.Bl -tag -width xxxx
10019fd0dafcSJoerg Wunsch.It EX_USAGE
10029fd0dafcSJoerg Wunsch.Bl -bullet -compact
10039fd0dafcSJoerg Wunsch.It
10041dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option).
10059fd0dafcSJoerg Wunsch.El
10069fd0dafcSJoerg Wunsch.It EX_NOPERM
10079fd0dafcSJoerg Wunsch.Bl -bullet -compact
10089fd0dafcSJoerg Wunsch.It
10099fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root.
10109fd0dafcSJoerg Wunsch.El
10119fd0dafcSJoerg Wunsch.It EX_OSERR
10129fd0dafcSJoerg Wunsch.Bl -bullet -compact
10139fd0dafcSJoerg Wunsch.It
10149fd0dafcSJoerg WunschMemory allocation error.
10159fd0dafcSJoerg Wunsch.It
10169fd0dafcSJoerg WunschRead error from password file descriptor.
10179fd0dafcSJoerg Wunsch.El
10189fd0dafcSJoerg Wunsch.It EX_DATAERR
10199fd0dafcSJoerg Wunsch.Bl -bullet -compact
10209fd0dafcSJoerg Wunsch.It
10219fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or
1022137db389SSteve Pricevia the password file descriptor.
10239fd0dafcSJoerg Wunsch.It
10249fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid.
10259fd0dafcSJoerg Wunsch.El
10269fd0dafcSJoerg Wunsch.It EX_OSFILE
10279fd0dafcSJoerg Wunsch.Bl -bullet -compact
10289fd0dafcSJoerg Wunsch.It
10299fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist.
10309fd0dafcSJoerg Wunsch.It
10319fd0dafcSJoerg WunschBase home directory is invalid or does not exist.
10329fd0dafcSJoerg Wunsch.It
1033137db389SSteve PriceInvalid or non-existent shell specified.
10349fd0dafcSJoerg Wunsch.El
10359fd0dafcSJoerg Wunsch.It EX_NOUSER
10369fd0dafcSJoerg Wunsch.Bl -bullet -compact
10379fd0dafcSJoerg Wunsch.It
10389fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist.
10399fd0dafcSJoerg Wunsch.It
1040137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared.
10419fd0dafcSJoerg Wunsch.El
10429fd0dafcSJoerg Wunsch.It EX_SOFTWARE
10439fd0dafcSJoerg Wunsch.Bl -bullet -compact
10449fd0dafcSJoerg Wunsch.It
10459fd0dafcSJoerg WunschNo more group or user ids available within specified range.
10469fd0dafcSJoerg Wunsch.El
10479fd0dafcSJoerg Wunsch.It EX_IOERR
10489fd0dafcSJoerg Wunsch.Bl -bullet -compact
10499fd0dafcSJoerg Wunsch.It
10509fd0dafcSJoerg WunschUnable to rewrite configuration file.
10519fd0dafcSJoerg Wunsch.It
10529fd0dafcSJoerg WunschError updating group or user database files.
10539fd0dafcSJoerg Wunsch.It
10549fd0dafcSJoerg WunschUpdate error for passwd or group database files.
10559fd0dafcSJoerg Wunsch.El
10569fd0dafcSJoerg Wunsch.It EX_CONFIG
10579fd0dafcSJoerg Wunsch.Bl -bullet -compact
10589fd0dafcSJoerg Wunsch.It
10599fd0dafcSJoerg WunschNo base home directory configured.
10609fd0dafcSJoerg Wunsch.El
10619fd0dafcSJoerg Wunsch.El
1062d6f907dcSJoerg Wunsch.Sh SEE ALSO
1063d6f907dcSJoerg Wunsch.Xr chpass 1 ,
1064053375e8SMike Pritchard.Xr passwd 1 ,
1065eebbeceeSLukas Ertl.Xr umask 2 ,
1066d6f907dcSJoerg Wunsch.Xr group 5 ,
1067bfd34a4aSWolfram Schneider.Xr login.conf 5 ,
1068053375e8SMike Pritchard.Xr passwd 5 ,
1069053375e8SMike Pritchard.Xr pw.conf 5 ,
1070d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 ,
1071053375e8SMike Pritchard.Xr vipw 8
1072d6f907dcSJoerg Wunsch.Sh HISTORY
1073490d5836SPhilippe CharnierThe
1074490d5836SPhilippe Charnier.Nm
1075490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV
1076d6f907dcSJoerg Wunsch.Em shadow
10779fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to
1078053375e8SMike Pritchardthe
1079053375e8SMike Pritchard.Bx 4.4
10809fd0dafcSJoerg Wunschoperating system, and combines all of the major elements
10819fd0dafcSJoerg Wunschinto a single command.
1082