xref: /freebsd/usr.sbin/pw/pw.8 (revision 1cbe5012cfe10226dd365af325a01de5d4c15f5d)
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.\"
27*1cbe5012SEugene Grosbein.Dd November 28, 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
395243e560SMateusz 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
555243e560SMateusz 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
745243e560SMateusz 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
805243e560SMateusz Piotrowski.Op Fl r
815243e560SMateusz 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
875243e560SMateusz 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
1035243e560SMateusz 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.
544adf9cd56SMateusz PiotrowskiSee
545adf9cd56SMateusz Piotrowski.Xr openssl-passwd 1
546adf9cd56SMateusz Piotrowskiand
547adf9cd56SMateusz Piotrowski.Xr crypt 3
548adf9cd56SMateusz Piotrowskifor more details about generating an encrypted password hash.
549d6f907dcSJoerg Wunsch.El
550d6f907dcSJoerg Wunsch.Pp
551d6f907dcSJoerg WunschIt is possible to use
55277fd0356SMateusz Piotrowski.Cm useradd
553d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id.
554d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the
55508657612SRuslan Ermilov.Fl o
5569fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of
5579fd0dafcSJoerg Wunschthe user id.
5589fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under
5599fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home
5609fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same
5619fd0dafcSJoerg Wunschpermissions for access to the user's files in each account.
562d6f907dcSJoerg Wunsch.Pp
563d6f907dcSJoerg WunschThe
56477fd0356SMateusz Piotrowski.Cm useradd
565d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the
56608657612SRuslan Ermilov.Fl D
5679fd0dafcSJoerg Wunschoption.
568d6f907dcSJoerg WunschInstead of adding a new user,
5691dcc6ec7SPhilippe Charnier.Nm
570d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file,
571d6f907dcSJoerg Wunsch.Pa /etc/pw.conf .
572d6f907dcSJoerg WunschWhen using the
57308657612SRuslan Ermilov.Fl D
5749fd0dafcSJoerg Wunschoption, you must not use either
57508657612SRuslan Ermilov.Fl n Ar name
576d6f907dcSJoerg Wunschor
57708657612SRuslan Ermilov.Fl u Ar uid
578d6f907dcSJoerg Wunschor an error will result.
579d6f907dcSJoerg WunschUse of
58008657612SRuslan Ermilov.Fl D
5819fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the
582d6f907dcSJoerg Wunsch.Ar useradd
583d6f907dcSJoerg Wunschcommand.
584d6f907dcSJoerg WunschThese are:
585d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
586d6f907dcSJoerg Wunsch.It Fl D
587d6f907dcSJoerg WunschSet default values in
588d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
589d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the
59008657612SRuslan Ermilov.Fl C Ar config
5919fd0dafcSJoerg Wunschoption is used.
592feb04c7bSMateusz Piotrowski.It Fl b Ar basehome
5931dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created.
594d6f907dcSJoerg WunschThe default value for this is
5951dcc6ec7SPhilippe Charnier.Pa /home ,
596d6f907dcSJoerg Wunschbut it may be set elsewhere as desired.
597feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdays
5981dcc6ec7SPhilippe CharnierSet the default account expiration period in days.
5991e4d5cf1SDevin TeskeWhen
6001e4d5cf1SDevin Teske.Fl D
6011e4d5cf1SDevin Teskeis used, the
602feb04c7bSMateusz Piotrowski.Ar accexpdays
6031e4d5cf1SDevin Teskeargument is interpreted differently.
6041e4d5cf1SDevin TeskeIt must be numeric and represents the number of days after creation
6051e4d5cf1SDevin Teskethat the account expires.
606d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date.
607feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdays
6081dcc6ec7SPhilippe CharnierSet the default password expiration period in days.
609d30f122fSEugene GrosbeinWhen
610d30f122fSEugene Grosbein.Fl D
611d30f122fSEugene Grosbeinis used, the
612feb04c7bSMateusz Piotrowski.Ar passexpdays
613d30f122fSEugene Grosbeinargument is interpreted differently.
614d30f122fSEugene GrosbeinIt must be numeric and represents the number of days after creation
615d30f122fSEugene Grosbeinthat the account expires.
616d30f122fSEugene GrosbeinA value of 0 suppresses automatic calculation of the expiry date.
617d6f907dcSJoerg Wunsch.It Fl g Ar group
6181dcc6ec7SPhilippe CharnierSet the default group for new users.
619d6f907dcSJoerg WunschIf a blank group is specified using
62008657612SRuslan Ermilov.Fl g Ar \&"" ,
621137db389SSteve Pricethen new users will be allocated their own private primary group
622137db389SSteve Pricewith the same name as their login name.
623d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument.
624d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
625137db389SSteve PriceSet the default groups in which new users are granted membership.
6261e4d5cf1SDevin TeskeThis is a separate set of groups from the primary group.
6271e4d5cf1SDevin TeskeAvoid nominating the same group as both primary and extra groups.
628d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups
629d6f907dcSJoerg Wunsch.Em other than
630d6f907dcSJoerg Wunschthe primary group.
631d6f907dcSJoerg Wunsch.Ar grouplist
632137db389SSteve Priceis a comma-separated list of group names or ids, and are always
633d6f907dcSJoerg Wunschstored in
634d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
635d6f907dcSJoerg Wunschby their symbolic names.
6369fd0dafcSJoerg Wunsch.It Fl L Ar class
6379fd0dafcSJoerg WunschThis option sets the default login class for new users.
638feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir
6391dcc6ec7SPhilippe CharnierSet the default
640d6f907dcSJoerg Wunsch.Em skeleton
6411e4d5cf1SDevin Teskedirectory,
6421e4d5cf1SDevin Teskefrom which prototype shell and other initialization files are copied when
6431dcc6ec7SPhilippe Charnier.Nm
644d6f907dcSJoerg Wunschcreates a user's home directory.
64531e224ddSTom RhodesSee description of
64631e224ddSTom Rhodes.Fl k
64731e224ddSTom Rhodesfor naming conventions of these files.
648610a5778SRuslan Ermilov.It Xo
649feb04c7bSMateusz Piotrowski.Fl u Ar minuid Ns Cm \&, Ns Ar maxuid ,
650feb04c7bSMateusz Piotrowski.Fl i Ar mingid Ns Cm \&, Ns Ar maxgid
651610a5778SRuslan Ermilov.Xc
6521e4d5cf1SDevin TeskeSet the minimum and maximum user and group ids allocated for new
6531e4d5cf1SDevin Teskeaccounts and groups created by
654e97407b4SRuslan Ermilov.Nm .
655d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum.
656feb04c7bSMateusz Piotrowski.Ar minuid
657d6f907dcSJoerg Wunschand
658feb04c7bSMateusz Piotrowski.Ar maxuid
6591e4d5cf1SDevin Teskeare both numbers, where max must be greater than min,
660feb04c7bSMateusz Piotrowskiand both must be between 0 and 32767
661feb04c7bSMateusz Piotrowski.Po the same applies to
662feb04c7bSMateusz Piotrowski.Ar mingid
663feb04c7bSMateusz Piotrowskiand
664feb04c7bSMateusz Piotrowski.Ar maxgid
665feb04c7bSMateusz Piotrowski.Pc .
6661e4d5cf1SDevin TeskeIn general,
6671e4d5cf1SDevin Teskeuser and group ids less than 100 are reserved for use by the system,
6681e4d5cf1SDevin Teskeand numbers greater than 32000 may also be reserved for special purposes
6691e4d5cf1SDevin Teske.Pq used by some system daemons .
670feb04c7bSMateusz Piotrowski.It Fl w Ar passmethod
671d6f907dcSJoerg WunschThe
67208657612SRuslan Ermilov.Fl w
6731e4d5cf1SDevin Teskeoption selects the default method used to set passwords for newly created user
6741e4d5cf1SDevin Teskeaccounts.
675feb04c7bSMateusz Piotrowski.Ar passmethod
676d6f907dcSJoerg Wunschis one of:
677d6f907dcSJoerg Wunsch.Pp
678d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact
67977fd0356SMateusz Piotrowski.It Cm no
6801dcc6ec7SPhilippe Charnierdisable login on newly created accounts
68177fd0356SMateusz Piotrowski.It Cm yes
6821dcc6ec7SPhilippe Charnierforce the password to be the account name
68377fd0356SMateusz Piotrowski.It Cm none
6841dcc6ec7SPhilippe Charnierforce a blank password
68577fd0356SMateusz Piotrowski.It Cm random
6861dcc6ec7SPhilippe Charniergenerate a random password
687d6f907dcSJoerg Wunsch.El
688d6f907dcSJoerg Wunsch.Pp
689d6f907dcSJoerg WunschThe
69077fd0356SMateusz Piotrowski.Cm random
691d6f907dcSJoerg Wunschor
69277fd0356SMateusz Piotrowski.Cm no
693d6f907dcSJoerg Wunschmethods are the most secure; in the former case,
6941dcc6ec7SPhilippe Charnier.Nm
6951e4d5cf1SDevin Teskegenerates a password and prints it to stdout,
6961e4d5cf1SDevin Teskewhich is suitable when users are issued passwords rather than being allowed
6971e4d5cf1SDevin Tesketo select their own
6981e4d5cf1SDevin Teske.Pq possibly poorly chosen
6991e4d5cf1SDevin Teskepassword.
700d6f907dcSJoerg WunschThe
70177fd0356SMateusz Piotrowski.Cm no
702d6f907dcSJoerg Wunschmethod requires that the superuser use
703d6f907dcSJoerg Wunsch.Xr passwd 1
704d6f907dcSJoerg Wunschto render the account accessible with a password.
705f1d684faSDavid Nugent.It Fl y Ar path
706490d5836SPhilippe CharnierThis sets the pathname of the database used by
707490d5836SPhilippe Charnier.Tn NIS
708490d5836SPhilippe Charnierif you are not sharing
709f1d684faSDavid Nugentthe information from
710f1d684faSDavid Nugent.Pa /etc/master.passwd
711490d5836SPhilippe Charnierdirectly with
712490d5836SPhilippe Charnier.Tn NIS .
713490d5836SPhilippe CharnierYou should only set this option for
714490d5836SPhilippe Charnier.Tn NIS
715490d5836SPhilippe Charnierservers.
716d6f907dcSJoerg Wunsch.El
717d6f907dcSJoerg Wunsch.Pp
718d6f907dcSJoerg WunschThe
71977fd0356SMateusz Piotrowski.Cm userdel
7201e4d5cf1SDevin Teskecommand has three distinct options.
721f2e366a1SSheldon HearnThe
72208657612SRuslan Ermilov.Fl n Ar name
723d6f907dcSJoerg Wunschand
72408657612SRuslan Ermilov.Fl u Ar uid
7259fd0dafcSJoerg Wunschoptions have already been covered above.
7269fd0dafcSJoerg WunschThe additional option is:
7279fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
728d6f907dcSJoerg Wunsch.It Fl r
729d6f907dcSJoerg WunschThis tells
7301dcc6ec7SPhilippe Charnier.Nm
731d6f907dcSJoerg Wunschto remove the user's home directory and all of its contents.
732490d5836SPhilippe CharnierThe
733490d5836SPhilippe Charnier.Nm
734490d5836SPhilippe Charnierutility errs on the side of caution when removing files from the system.
7351e4d5cf1SDevin TeskeFirstly,
7361e4d5cf1SDevin Teskeit will not do so if the uid of the account being removed is also used by
73777fd0356SMateusz Piotrowskianother account on the system, and the
73877fd0356SMateusz Piotrowski.Dq home
73977fd0356SMateusz Piotrowskidirectory in the password file is
740d6f907dcSJoerg Wunscha valid path that commences with the character
741d6f907dcSJoerg Wunsch.Ql \&/ .
742d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by
743d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory.
744d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories
745d6f907dcSJoerg Wunschwill be removed.
746053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator.
747d6f907dcSJoerg Wunsch.El
748d6f907dcSJoerg Wunsch.Pp
74977fd0356SMateusz PiotrowskiMail spool files and
75077fd0356SMateusz Piotrowski.Xr crontab 5
75177fd0356SMateusz Piotrowskifiles are always removed when an account is deleted as
7521e4d5cf1SDevin Teskethese are unconditionally attached to the user name.
753d6f907dcSJoerg WunschJobs queued for processing by
75477fd0356SMateusz Piotrowski.Xr at 1
7551e4d5cf1SDevin Teskeare also removed if the user's uid is unique and not also used by another
7561e4d5cf1SDevin Teskeaccount on the system.
757d6f907dcSJoerg Wunsch.Pp
758d6f907dcSJoerg WunschThe
75977fd0356SMateusz Piotrowski.Cm usermod
76019e1bf29SEitan Adlercommand adds one additional option:
76119e1bf29SEitan Adler.Bl -tag -width "-G grouplist"
7621e4d5cf1SDevin Teske.It Fl l Ar newname
76319e1bf29SEitan AdlerThis option allows changing of an existing account name to
76477fd0356SMateusz Piotrowski.Ar newname .
76519e1bf29SEitan AdlerThe new name must not already exist, and any attempt to duplicate an
76619e1bf29SEitan Adlerexisting account name will be rejected.
76719e1bf29SEitan Adler.El
76819e1bf29SEitan Adler.Pp
76919e1bf29SEitan AdlerThe
77077fd0356SMateusz Piotrowski.Cm usershow
771d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats.
772d6f907dcSJoerg WunschBy default, the format is identical to the format used in
773d6f907dcSJoerg Wunsch.Pa /etc/master.passwd
774d6f907dcSJoerg Wunschwith the password field replaced with a
775d6f907dcSJoerg Wunsch.Ql \&* .
776d6f907dcSJoerg WunschIf the
77708657612SRuslan Ermilov.Fl P
7789fd0dafcSJoerg Wunschoption is used, then
7791dcc6ec7SPhilippe Charnier.Nm
780d6f907dcSJoerg Wunschoutputs the account details in a more human readable form.
7814731d076SDima DorfmanIf the
7824731d076SDima Dorfman.Fl 7
7834731d076SDima Dorfmanoption is used, the account details are shown in v7 format.
784d6f907dcSJoerg WunschThe
78508657612SRuslan Ermilov.Fl a
7869fd0dafcSJoerg Wunschoption lists all users currently on file.
787466c257cSDima DorfmanUsing
788466c257cSDima Dorfman.Fl F
789466c257cSDima Dorfmanforces
790466c257cSDima Dorfman.Nm
791466c257cSDima Dorfmanto print the details of an account even if it does not exist.
7929fd0dafcSJoerg Wunsch.Pp
7939fd0dafcSJoerg WunschThe command
79477fd0356SMateusz Piotrowski.Cm usernext
7959fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon.
7969fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends
7979fd0dafcSJoerg Wunschthat use
798e97407b4SRuslan Ermilov.Nm .
799d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS
800d6f907dcSJoerg WunschThe
80108657612SRuslan Ermilov.Fl C
802d6f907dcSJoerg Wunschand
80308657612SRuslan Ermilov.Fl q
8049fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available
8059fd0dafcSJoerg Wunschwith the group manipulation commands.
806d6f907dcSJoerg WunschOther common options to all group-related commands are:
8079fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8081e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name
8091e4d5cf1SDevin TeskeRequired unless
8101e4d5cf1SDevin Teske.Fl g Ar gid
8111e4d5cf1SDevin Teskeis given.
8121dcc6ec7SPhilippe CharnierSpecify the group name.
8131e4d5cf1SDevin TeskeIn the case of
81477fd0356SMateusz Piotrowski.Cm groupmod
8151e4d5cf1SDevin Teskecan be a gid.
816d6f907dcSJoerg Wunsch.It Fl g Ar gid
8171e4d5cf1SDevin TeskeRequired if
8181e4d5cf1SDevin Teske.Ar name
8191e4d5cf1SDevin Teskeis not given.
8201dcc6ec7SPhilippe CharnierSpecify the group numeric id.
8211e4d5cf1SDevin TeskeIn the case of
82277fd0356SMateusz Piotrowski.Cm groupmod
8231e4d5cf1SDevin Teskeif paired with
8241e4d5cf1SDevin Teske.Ar name ,
8251e4d5cf1SDevin Teskechanges the numeric id of the named group.
826d6f907dcSJoerg Wunsch.Pp
8279fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need
8289fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice
8299fd0dafcSJoerg Wunschversa.
8309fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id
8319fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group.
8327ecd7a42SJoseph Koshy.It Fl M Ar memberlist
8339fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a
83477fd0356SMateusz Piotrowskinew group
83577fd0356SMateusz Piotrowski.Pq in Cm groupadd
83677fd0356SMateusz Piotrowskior replace an existing membership list
83777fd0356SMateusz Piotrowski.Pq in Cm groupmod .
8389fd0dafcSJoerg Wunsch.Ar memberlist
8399fd0dafcSJoerg Wunschis a comma separated list of valid and existing user names or uids.
8409fd0dafcSJoerg Wunsch.It Fl m Ar newmembers
8419fd0dafcSJoerg WunschSimilar to
84208657612SRuslan Ermilov.Fl M ,
8439fd0dafcSJoerg Wunschthis option allows the
8449fd0dafcSJoerg Wunsch.Em addition
845137db389SSteve Priceof existing users to a group without replacing the existing list of
8469fd0dafcSJoerg Wunschmembers.
847137db389SSteve PriceLogin names or user ids may be used, and duplicate users are
848137db389SSteve Pricesilently eliminated.
849bc991a6dSSean Farley.It Fl d Ar oldmembers
850bc991a6dSSean FarleySimilar to
851bc991a6dSSean Farley.Fl M ,
852bc991a6dSSean Farleythis option allows the
853bc991a6dSSean Farley.Em deletion
854bc991a6dSSean Farleyof existing users from a group without replacing the existing list of
855bc991a6dSSean Farleymembers.
856bc991a6dSSean FarleyLogin names or user ids may be used, and duplicate users are
857bc991a6dSSean Farleysilently eliminated.
858d6f907dcSJoerg Wunsch.El
859d6f907dcSJoerg Wunsch.Pp
86077fd0356SMateusz Piotrowski.Cm groupadd
861d6f907dcSJoerg Wunschalso has a
86208657612SRuslan Ermilov.Fl o
863137db389SSteve Priceoption that allows allocation of an existing group id to a new group.
8641e4d5cf1SDevin TeskeThe default action is to reject an attempt to add a group,
8651e4d5cf1SDevin Teskeand this option overrides the check for duplicate group ids.
866d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id.
867d6f907dcSJoerg Wunsch.Pp
868d6f907dcSJoerg WunschThe
86977fd0356SMateusz Piotrowski.Cm groupmod
870137db389SSteve Pricecommand adds one additional option:
8719fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8721e4d5cf1SDevin Teske.It Fl l Ar newname
873d6f907dcSJoerg WunschThis option allows changing of an existing group name to
87477fd0356SMateusz Piotrowski.Ar newname .
8751e4d5cf1SDevin TeskeThe new name must not already exist,
8761e4d5cf1SDevin Teskeand any attempt to duplicate an existing group
877d6f907dcSJoerg Wunschname will be rejected.
878d6f907dcSJoerg Wunsch.El
879d6f907dcSJoerg Wunsch.Pp
880d6f907dcSJoerg WunschOptions for
88177fd0356SMateusz Piotrowski.Cm groupshow
882d6f907dcSJoerg Wunschare the same as for
88377fd0356SMateusz Piotrowski.Cm usershow ,
884d6f907dcSJoerg Wunschwith the
88508657612SRuslan Ermilov.Fl g Ar gid
886d6f907dcSJoerg Wunschreplacing
88708657612SRuslan Ermilov.Fl u Ar uid
888d6f907dcSJoerg Wunschto specify the group id.
8894731d076SDima DorfmanThe
8904731d076SDima Dorfman.Fl 7
8914731d076SDima Dorfmanoption does not apply to the
89277fd0356SMateusz Piotrowski.Cm groupshow
8934731d076SDima Dorfmancommand.
894d6f907dcSJoerg Wunsch.Pp
8959fd0dafcSJoerg WunschThe command
89677fd0356SMateusz Piotrowski.Cm groupnext
8979fd0dafcSJoerg Wunschreturns the next available group id on standard output.
898e468afb4SDima Dorfman.Sh USER LOCKING
899490d5836SPhilippe CharnierThe
900490d5836SPhilippe Charnier.Nm
901490d5836SPhilippe Charnierutility
902e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by
903e468afb4SDima Dorfmanprepending the string
904e468afb4SDima Dorfman.Ql *LOCKED*
905e468afb4SDima Dorfmanto the beginning of the password field in
90677fd0356SMateusz Piotrowski.Xr master.passwd 5
907e468afb4SDima Dorfmanto prevent successful authentication.
908e468afb4SDima Dorfman.Pp
909e468afb4SDima DorfmanThe
91077fd0356SMateusz Piotrowski.Cm lock
911e468afb4SDima Dorfmanand
91277fd0356SMateusz Piotrowski.Cm unlock
913e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock,
91407bfccd7SRuslan Ermilovrespectively.
91507bfccd7SRuslan ErmilovThe
91608657612SRuslan Ermilov.Fl V ,
91708657612SRuslan Ermilov.Fl C ,
918e468afb4SDima Dorfmanand
91908657612SRuslan Ermilov.Fl q
920e468afb4SDima Dorfmanoptions as described above are accepted by these commands.
92159a3c79dSRuslan Ermilov.Sh NOTES
92259a3c79dSRuslan ErmilovFor a summary of options available with each command, you can use
92359a3c79dSRuslan Ermilov.Dl pw [command] help
92459a3c79dSRuslan ErmilovFor example,
92559a3c79dSRuslan Ermilov.Dl pw useradd help
92677fd0356SMateusz Piotrowskilists all available options for the
92777fd0356SMateusz Piotrowski.Cm useradd
92877fd0356SMateusz Piotrowskioperation.
92959a3c79dSRuslan Ermilov.Pp
93059a3c79dSRuslan ErmilovThe
93159a3c79dSRuslan Ermilov.Nm
93259a3c79dSRuslan Ermilovutility allows 8-bit characters in the passwd GECOS field (user's full name,
93359a3c79dSRuslan Ermilovoffice, work and home phone number subfields), but disallows them in
93459a3c79dSRuslan Ermilovuser login and group names.
93559a3c79dSRuslan ErmilovUse 8-bit characters with caution, as connection to the Internet will
93659a3c79dSRuslan Ermilovrequire that your mail transport program supports 8BITMIME, and will
93759a3c79dSRuslan Ermilovconvert headers containing 8-bit characters to 7-bit quoted-printable
93859a3c79dSRuslan Ermilovformat.
93959a3c79dSRuslan Ermilov.Xr sendmail 8
94059a3c79dSRuslan Ermilovdoes support this.
94159a3c79dSRuslan ErmilovUse of 8-bit characters in the GECOS field should be used in
94259a3c79dSRuslan Ermilovconjunction with the user's default locale and character set
94359a3c79dSRuslan Ermilovand should not be implemented without their use.
94459a3c79dSRuslan ErmilovUsing 8-bit characters may also affect other
94559a3c79dSRuslan Ermilovprograms that transmit the contents of the GECOS field over the
94659a3c79dSRuslan ErmilovInternet, such as
94759a3c79dSRuslan Ermilov.Xr fingerd 8 ,
94859a3c79dSRuslan Ermilovand a small number of TCP/IP clients, such as IRC, where full names
94959a3c79dSRuslan Ermilovspecified in the passwd file may be used by default.
95059a3c79dSRuslan Ermilov.Pp
95159a3c79dSRuslan ErmilovThe
95259a3c79dSRuslan Ermilov.Nm
95359a3c79dSRuslan Ermilovutility writes a log to the
95459a3c79dSRuslan Ermilov.Pa /var/log/userlog
95559a3c79dSRuslan Ermilovfile when actions such as user or group additions or deletions occur.
95659a3c79dSRuslan ErmilovThe location of this logfile can be changed in
95759a3c79dSRuslan Ermilov.Xr pw.conf 5 .
95859a3c79dSRuslan Ermilov.Sh FILES
95959a3c79dSRuslan Ermilov.Bl -tag -width /etc/master.passwd.new -compact
96059a3c79dSRuslan Ermilov.It Pa /etc/master.passwd
96159a3c79dSRuslan ErmilovThe user database
96259a3c79dSRuslan Ermilov.It Pa /etc/passwd
96359a3c79dSRuslan ErmilovA Version 7 format password file
96459a3c79dSRuslan Ermilov.It Pa /etc/login.conf
96559a3c79dSRuslan ErmilovThe user capabilities database
96659a3c79dSRuslan Ermilov.It Pa /etc/group
96759a3c79dSRuslan ErmilovThe group database
96859a3c79dSRuslan Ermilov.It Pa /etc/pw.conf
96959a3c79dSRuslan ErmilovPw default options file
97059a3c79dSRuslan Ermilov.It Pa /var/log/userlog
97159a3c79dSRuslan ErmilovUser/group modification logfile
97259a3c79dSRuslan Ermilov.El
9739b8a603eSWarren Block.Sh EXAMPLES
9749b8a603eSWarren BlockAdd new user Glurmo Smith (gsmith).
9759b8a603eSWarren BlockA gsmith login group is created if not already present.
9769b8a603eSWarren BlockThe login shell is set to
9779b8a603eSWarren Block.Xr csh 1 .
9789b8a603eSWarren BlockA new home directory at
9799b8a603eSWarren Block.Pa /home/gsmith
9809b8a603eSWarren Blockis created if it does not already exist.
9819b8a603eSWarren BlockFinally, a random password is generated and displayed:
9829b8a603eSWarren Block.Bd -literal -offset indent
98384733f2eSMateusz Piotrowskipw useradd -n gsmith -c "Glurmo Smith" -s csh -m -w random
9849b8a603eSWarren Block.Ed
985bb00e549SWarren Block.Pp
986bb00e549SWarren BlockDelete the gsmith user and their home directory, including contents.
987bb00e549SWarren Block.Bd -literal -offset indent
988bb00e549SWarren Blockpw userdel -n gsmith -r
989bb00e549SWarren Block.Ed
99060c81cf1SBenedict Reuschling.Pp
99160c81cf1SBenedict ReuschlingAdd the existing user jsmith to the wheel group,
99260c81cf1SBenedict Reuschlingin addition to the other groups jsmith is already a member of.
99360c81cf1SBenedict Reuschling.Bd -literal -offset indent
99460c81cf1SBenedict Reuschlingpw groupmod wheel -m jsmith
99560c81cf1SBenedict Reuschling.Ed
996*1cbe5012SEugene Grosbein.Pp
997*1cbe5012SEugene GrosbeinGenerate random password and show it in both plain text and
998*1cbe5012SEugene Grosbeinencrypted form not modifying any database.
999*1cbe5012SEugene Grosbein.Bd -literal -offset indent
1000*1cbe5012SEugene Grosbeinpw usermod nobody -Nw random
1001*1cbe5012SEugene Grosbein.Ed
1002a866e170SRuslan Ermilov.Sh EXIT STATUS
1003490d5836SPhilippe CharnierThe
1004490d5836SPhilippe Charnier.Nm
1005490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise
1006137db389SSteve Price.Nm
1007137db389SSteve Pricereturns one of the
10089fd0dafcSJoerg Wunschfollowing exit codes defined by
10099fd0dafcSJoerg Wunsch.Xr sysexits 3
10109fd0dafcSJoerg Wunschas follows:
10119fd0dafcSJoerg Wunsch.Bl -tag -width xxxx
10129fd0dafcSJoerg Wunsch.It EX_USAGE
10139fd0dafcSJoerg Wunsch.Bl -bullet -compact
10149fd0dafcSJoerg Wunsch.It
10151dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option).
10169fd0dafcSJoerg Wunsch.El
10179fd0dafcSJoerg Wunsch.It EX_NOPERM
10189fd0dafcSJoerg Wunsch.Bl -bullet -compact
10199fd0dafcSJoerg Wunsch.It
10209fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root.
10219fd0dafcSJoerg Wunsch.El
10229fd0dafcSJoerg Wunsch.It EX_OSERR
10239fd0dafcSJoerg Wunsch.Bl -bullet -compact
10249fd0dafcSJoerg Wunsch.It
10259fd0dafcSJoerg WunschMemory allocation error.
10269fd0dafcSJoerg Wunsch.It
10279fd0dafcSJoerg WunschRead error from password file descriptor.
10289fd0dafcSJoerg Wunsch.El
10299fd0dafcSJoerg Wunsch.It EX_DATAERR
10309fd0dafcSJoerg Wunsch.Bl -bullet -compact
10319fd0dafcSJoerg Wunsch.It
10329fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or
1033137db389SSteve Pricevia the password file descriptor.
10349fd0dafcSJoerg Wunsch.It
10359fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid.
10369fd0dafcSJoerg Wunsch.El
10379fd0dafcSJoerg Wunsch.It EX_OSFILE
10389fd0dafcSJoerg Wunsch.Bl -bullet -compact
10399fd0dafcSJoerg Wunsch.It
10409fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist.
10419fd0dafcSJoerg Wunsch.It
10429fd0dafcSJoerg WunschBase home directory is invalid or does not exist.
10439fd0dafcSJoerg Wunsch.It
1044137db389SSteve PriceInvalid or non-existent shell specified.
10459fd0dafcSJoerg Wunsch.El
10469fd0dafcSJoerg Wunsch.It EX_NOUSER
10479fd0dafcSJoerg Wunsch.Bl -bullet -compact
10489fd0dafcSJoerg Wunsch.It
10499fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist.
10509fd0dafcSJoerg Wunsch.It
1051137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared.
10529fd0dafcSJoerg Wunsch.El
10539fd0dafcSJoerg Wunsch.It EX_SOFTWARE
10549fd0dafcSJoerg Wunsch.Bl -bullet -compact
10559fd0dafcSJoerg Wunsch.It
10569fd0dafcSJoerg WunschNo more group or user ids available within specified range.
10579fd0dafcSJoerg Wunsch.El
10589fd0dafcSJoerg Wunsch.It EX_IOERR
10599fd0dafcSJoerg Wunsch.Bl -bullet -compact
10609fd0dafcSJoerg Wunsch.It
10619fd0dafcSJoerg WunschUnable to rewrite configuration file.
10629fd0dafcSJoerg Wunsch.It
10639fd0dafcSJoerg WunschError updating group or user database files.
10649fd0dafcSJoerg Wunsch.It
10659fd0dafcSJoerg WunschUpdate error for passwd or group database files.
10669fd0dafcSJoerg Wunsch.El
10679fd0dafcSJoerg Wunsch.It EX_CONFIG
10689fd0dafcSJoerg Wunsch.Bl -bullet -compact
10699fd0dafcSJoerg Wunsch.It
10709fd0dafcSJoerg WunschNo base home directory configured.
10719fd0dafcSJoerg Wunsch.El
10729fd0dafcSJoerg Wunsch.El
1073d6f907dcSJoerg Wunsch.Sh SEE ALSO
1074d6f907dcSJoerg Wunsch.Xr chpass 1 ,
1075053375e8SMike Pritchard.Xr passwd 1 ,
1076eebbeceeSLukas Ertl.Xr umask 2 ,
1077d6f907dcSJoerg Wunsch.Xr group 5 ,
1078bfd34a4aSWolfram Schneider.Xr login.conf 5 ,
1079053375e8SMike Pritchard.Xr passwd 5 ,
1080053375e8SMike Pritchard.Xr pw.conf 5 ,
1081d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 ,
1082053375e8SMike Pritchard.Xr vipw 8
1083d6f907dcSJoerg Wunsch.Sh HISTORY
1084490d5836SPhilippe CharnierThe
1085490d5836SPhilippe Charnier.Nm
1086490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV
1087d6f907dcSJoerg Wunsch.Em shadow
10889fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to
1089053375e8SMike Pritchardthe
1090053375e8SMike Pritchard.Bx 4.4
10919fd0dafcSJoerg Wunschoperating system, and combines all of the major elements
10929fd0dafcSJoerg Wunschinto a single command.
1093