xref: /freebsd/usr.sbin/pw/pw.8 (revision d573295659550cf4bfbf3aaaf97d050fe7416d77)
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.\"
25*d5732956SJose Luis Duran.Dd July 29, 2024
26d6f907dcSJoerg Wunsch.Dt PW 8
27d6f907dcSJoerg Wunsch.Os
28d6f907dcSJoerg Wunsch.Sh NAME
29d6f907dcSJoerg Wunsch.Nm pw
309fd0dafcSJoerg Wunsch.Nd create, remove, modify & display system users and groups
31d6f907dcSJoerg Wunsch.Sh SYNOPSIS
32e97407b4SRuslan Ermilov.Nm
33a5b912ffSGlen Barber.Op Fl R Ar rootdir
345f12594aSDavid Nugent.Op Fl V Ar etcdir
355392b4fbSMateusz Piotrowski.Cm useradd
3639245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name
375243e560SMateusz Piotrowski.Op Fl mNoPq
38d6f907dcSJoerg Wunsch.Op Fl C Ar config
39d6f907dcSJoerg Wunsch.Op Fl c Ar comment
40feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir
41feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate
42d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
4339245a7dSMateusz Piotrowski.Op Fl g Ar group
4439245a7dSMateusz Piotrowski.Op Fl H Ar fd
4539245a7dSMateusz Piotrowski.Op Fl h Ar fd
46feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
47d6f907dcSJoerg Wunsch.Op Fl L Ar class
4839245a7dSMateusz Piotrowski.Op Fl M Ar mode
49feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate
5039245a7dSMateusz Piotrowski.Op Fl s Ar shell
5139245a7dSMateusz Piotrowski.Op Fl u Ar uid
52feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
535243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
54e97407b4SRuslan Ermilov.Nm
55a5b912ffSGlen Barber.Op Fl R Ar rootdir
565f12594aSDavid Nugent.Op Fl V Ar etcdir
575392b4fbSMateusz Piotrowski.Cm useradd
58f1d684faSDavid Nugent.Fl D
59d6f907dcSJoerg Wunsch.Op Fl q
60feb04c7bSMateusz Piotrowski.Op Fl b Ar basehome
6139245a7dSMateusz Piotrowski.Op Fl C Ar config
62feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdays
63d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist
6439245a7dSMateusz Piotrowski.Op Fl g Ar group
65feb04c7bSMateusz Piotrowski.Op Fl i Ar mingid , Ns Ar maxgid
66feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
67a0177bd5SMateusz Piotrowski.Op Fl M Ar mode
68feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdays
6939245a7dSMateusz Piotrowski.Op Fl s Ar shell
70feb04c7bSMateusz Piotrowski.Op Fl u Ar minuid , Ns Ar maxuid
71feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
725243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
73e97407b4SRuslan Ermilov.Nm
74a5b912ffSGlen Barber.Op Fl R Ar rootdir
755f12594aSDavid Nugent.Op Fl V Ar etcdir
765392b4fbSMateusz Piotrowski.Cm userdel
7739245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
785243e560SMateusz Piotrowski.Op Fl r
795243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
80e97407b4SRuslan Ermilov.Nm
81a5b912ffSGlen Barber.Op Fl R Ar rootdir
825f12594aSDavid Nugent.Op Fl V Ar etcdir
835392b4fbSMateusz Piotrowski.Cm usermod
845392b4fbSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Ar uid Oo Fl u Ar newuid Oc | Fl u Ar uid
855243e560SMateusz Piotrowski.Op Fl mNPq
86d6f907dcSJoerg Wunsch.Op Fl C Ar config
87d6f907dcSJoerg Wunsch.Op Fl c Ar comment
88feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir
89feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate
90feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir
9139245a7dSMateusz Piotrowski.Op Fl G Ar grouplist
9239245a7dSMateusz Piotrowski.Op Fl g Ar group
9339245a7dSMateusz Piotrowski.Op Fl H Ar fd
9439245a7dSMateusz Piotrowski.Op Fl h Ar fd
95d6f907dcSJoerg Wunsch.Op Fl L Ar class
9639245a7dSMateusz Piotrowski.Op Fl l Ar newname
9739245a7dSMateusz Piotrowski.Op Fl M Ar mode
98feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate
9939245a7dSMateusz Piotrowski.Op Fl s Ar shell
100feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod
1015243e560SMateusz Piotrowski.Op Fl Y Op Fl y Ar nispasswd
102e97407b4SRuslan Ermilov.Nm
103a5b912ffSGlen Barber.Op Fl R Ar rootdir
1045f12594aSDavid Nugent.Op Fl V Ar etcdir
1055392b4fbSMateusz Piotrowski.Cm usershow
10639245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
10739245a7dSMateusz Piotrowski.Op Fl 7aFP
108e97407b4SRuslan Ermilov.Nm
109a5b912ffSGlen Barber.Op Fl R Ar rootdir
1105f12594aSDavid Nugent.Op Fl V Ar etcdir
1115392b4fbSMateusz Piotrowski.Cm usernext
1123bfc59e8SBaptiste Daroussin.Op Fl q
11339245a7dSMateusz Piotrowski.Op Fl C Ar config
114e97407b4SRuslan Ermilov.Nm
115a5b912ffSGlen Barber.Op Fl R Ar rootdir
1165f12594aSDavid Nugent.Op Fl V Ar etcdir
1175392b4fbSMateusz Piotrowski.Cm groupadd
11839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name
11939245a7dSMateusz Piotrowski.Op Fl oNPqY
120d6f907dcSJoerg Wunsch.Op Fl C Ar config
12139245a7dSMateusz Piotrowski.Op Fl g Ar gid
12239245a7dSMateusz Piotrowski.Op Fl H Ar fd
12339245a7dSMateusz Piotrowski.Op Fl h Ar fd
1249fd0dafcSJoerg Wunsch.Op Fl M Ar members
125e97407b4SRuslan Ermilov.Nm
126a5b912ffSGlen Barber.Op Fl R Ar rootdir
1275f12594aSDavid Nugent.Op Fl V Ar etcdir
1285392b4fbSMateusz Piotrowski.Cm groupdel
12939245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid
130f1d684faSDavid Nugent.Op Fl Y
131e97407b4SRuslan Ermilov.Nm
132a5b912ffSGlen Barber.Op Fl R Ar rootdir
1335f12594aSDavid Nugent.Op Fl V Ar etcdir
1345392b4fbSMateusz Piotrowski.Cm groupmod
1355392b4fbSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Ar gid Oo Fl g Ar newgid Oc | Fl g Ar gid
13639245a7dSMateusz Piotrowski.Op Fl NPqY
137d6f907dcSJoerg Wunsch.Op Fl C Ar config
13839245a7dSMateusz Piotrowski.Op Fl d Ar oldmembers
13939245a7dSMateusz Piotrowski.Op Fl H Ar fd
14039245a7dSMateusz Piotrowski.Op Fl h Ar fd
1411e4d5cf1SDevin Teske.Op Fl l Ar newname
1429fd0dafcSJoerg Wunsch.Op Fl M Ar members
1439fd0dafcSJoerg Wunsch.Op Fl m Ar newmembers
144e97407b4SRuslan Ermilov.Nm
145a5b912ffSGlen Barber.Op Fl R Ar rootdir
1465f12594aSDavid Nugent.Op Fl V Ar etcdir
1475392b4fbSMateusz Piotrowski.Cm groupshow
14839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid
14939245a7dSMateusz Piotrowski.Op Fl aFP
150e97407b4SRuslan Ermilov.Nm
151a5b912ffSGlen Barber.Op Fl R Ar rootdir
1525f12594aSDavid Nugent.Op Fl V Ar etcdir
1535392b4fbSMateusz Piotrowski.Cm groupnext
1549fd0dafcSJoerg Wunsch.Op Fl C Ar config
1553bfc59e8SBaptiste Daroussin.Op Fl q
156e468afb4SDima Dorfman.Nm
157a5b912ffSGlen Barber.Op Fl R Ar rootdir
158e468afb4SDima Dorfman.Op Fl V Ar etcdir
1595392b4fbSMateusz Piotrowski.Cm lock
16039245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
161e468afb4SDima Dorfman.Op Fl q
16239245a7dSMateusz Piotrowski.Op Fl C Ar config
163e468afb4SDima Dorfman.Nm
164a5b912ffSGlen Barber.Op Fl R Ar rootdir
165e468afb4SDima Dorfman.Op Fl V Ar etcdir
1665392b4fbSMateusz Piotrowski.Cm unlock
16739245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid
168e468afb4SDima Dorfman.Op Fl q
16939245a7dSMateusz Piotrowski.Op Fl C Ar config
170d6f907dcSJoerg Wunsch.Sh DESCRIPTION
171490d5836SPhilippe CharnierThe
172490d5836SPhilippe Charnier.Nm
173490d5836SPhilippe Charnierutility is a command-line based editor for the system
1741dcc6ec7SPhilippe Charnier.Ar user
175d6f907dcSJoerg Wunschand
1761dcc6ec7SPhilippe Charnier.Ar group
1773a7e7077SDaniel O'Callaghanfiles, allowing the superuser an easy to use and standardized way of adding,
178d6f907dcSJoerg Wunschmodifying and removing users and groups.
179d6f907dcSJoerg WunschNote that
1801dcc6ec7SPhilippe Charnier.Nm
181490d5836SPhilippe Charnieronly operates on the local user and group files.
182490d5836SPhilippe Charnier.Tn NIS
183490d5836SPhilippe Charnierusers and groups must be
184490d5836SPhilippe Charniermaintained on the
185490d5836SPhilippe Charnier.Tn NIS
186490d5836SPhilippe Charnierserver.
187490d5836SPhilippe CharnierThe
188490d5836SPhilippe Charnier.Nm
189490d5836SPhilippe Charnierutility handles updating the
19061e11ed9SMateusz Piotrowski.Xr passwd 5 ,
19161e11ed9SMateusz Piotrowski.Xr master.passwd 5 ,
19261e11ed9SMateusz Piotrowski.Xr group 5
193053375e8SMike Pritchardand the secure and insecure
194d6f907dcSJoerg Wunschpassword database files, and must be run as root.
195d6f907dcSJoerg Wunsch.Pp
196137db389SSteve PriceThe first one or two keywords provided to
197137db389SSteve Price.Nm
198137db389SSteve Priceon the command line provide the context for the remainder of the arguments.
199137db389SSteve PriceThe keywords
20061e11ed9SMateusz Piotrowski.Cm user
201d6f907dcSJoerg Wunschand
20261e11ed9SMateusz Piotrowski.Cm group
203137db389SSteve Pricemay be combined with
20461e11ed9SMateusz Piotrowski.Cm add ,
20561e11ed9SMateusz Piotrowski.Cm del ,
20661e11ed9SMateusz Piotrowski.Cm mod ,
20761e11ed9SMateusz Piotrowski.Cm show ,
2089fd0dafcSJoerg Wunschor
20961e11ed9SMateusz Piotrowski.Cm next
2104e86fcacSSheldon Hearnin any order.
2114e86fcacSSheldon Hearn(For example,
21261e11ed9SMateusz Piotrowski.Cm showuser ,
21361e11ed9SMateusz Piotrowski.Cm usershow ,
21461e11ed9SMateusz Piotrowski.Cm show user ,
215610a5778SRuslan Ermilovand
21661e11ed9SMateusz Piotrowski.Cm user show
217137db389SSteve Priceall mean the same thing.)
218137db389SSteve PriceThis flexibility is useful for interactive scripts calling
2191dcc6ec7SPhilippe Charnier.Nm
220137db389SSteve Pricefor user and group database manipulation.
2211e4d5cf1SDevin TeskeFollowing these keywords,
2221e4d5cf1SDevin Teskethe user or group name or numeric id may be optionally specified as an
2231e4d5cf1SDevin Teskealternative to using the
224d6f907dcSJoerg Wunsch.Fl n Ar name ,
225d6f907dcSJoerg Wunsch.Fl u Ar uid ,
226d6f907dcSJoerg Wunsch.Fl g Ar gid
2279fd0dafcSJoerg Wunschoptions.
228d6f907dcSJoerg Wunsch.Pp
229d5a3b1edSDima DorfmanThe following flags are common to most or all modes of operation:
2309fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
231a5b912ffSGlen Barber.It Fl R Ar rootdir
232a5b912ffSGlen BarberSpecifies an alternate root directory within which
233a5b912ffSGlen Barber.Nm
234a5b912ffSGlen Barberwill operate.
235a5b912ffSGlen BarberAny paths specified will be relative to
236a5b912ffSGlen Barber.Va rootdir .
2375f12594aSDavid Nugent.It Fl V Ar etcdir
2381e4d5cf1SDevin TeskeSet an alternate location for the password, group, and configuration files.
2391e4d5cf1SDevin TeskeCan be used to maintain a user/group database in an alternate location.
2405f12594aSDavid NugentIf this switch is specified, the system
2415f12594aSDavid Nugent.Pa /etc/pw.conf
2421e4d5cf1SDevin Teskewill not be sourced for default configuration data,
24361e11ed9SMateusz Piotrowskibut the file
24461e11ed9SMateusz Piotrowski.Pa pw.conf
24561e11ed9SMateusz Piotrowskiin the specified directory will be used instead
2461e4d5cf1SDevin Teske.Pq or none, if it does not exist .
2475f12594aSDavid NugentThe
2485f12594aSDavid Nugent.Fl C
2495f12594aSDavid Nugentflag may be used to override this behaviour.
2505f12594aSDavid NugentAs an exception to the general rule where options must follow the operation
2515f12594aSDavid Nugenttype, the
2525f12594aSDavid Nugent.Fl V
2534369c82dSBaptiste Daroussinflag must be used on the command line before the operation keyword.
254d6f907dcSJoerg Wunsch.It Fl C Ar config
255d6f907dcSJoerg WunschBy default,
2561dcc6ec7SPhilippe Charnier.Nm
257d6f907dcSJoerg Wunschreads the file
258d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
259137db389SSteve Priceto obtain policy information on how new user accounts and groups are to be created.
260137db389SSteve PriceThe
2619fd0dafcSJoerg Wunsch.Fl C
2629fd0dafcSJoerg Wunschoption specifies a different configuration file.
263137db389SSteve PriceWhile most of the contents of the configuration file may be overridden via
264137db389SSteve Pricecommand-line options, it may be more convenient to keep standard information in a
265137db389SSteve Priceconfiguration file.
266d6f907dcSJoerg Wunsch.It Fl q
267d6f907dcSJoerg WunschUse of this option causes
2681dcc6ec7SPhilippe Charnier.Nm
2691e4d5cf1SDevin Tesketo suppress error messages,
2701e4d5cf1SDevin Teskewhich may be useful in interactive environments where it
271d6f907dcSJoerg Wunschis preferable to interpret status codes returned by
2721dcc6ec7SPhilippe Charnier.Nm
273d6f907dcSJoerg Wunschrather than messing up a carefully formatted display.
2749fd0dafcSJoerg Wunsch.It Fl N
275137db389SSteve PriceThis option is available in
27661e11ed9SMateusz Piotrowski.Cm add
277137db389SSteve Priceand
27861e11ed9SMateusz Piotrowski.Cm modify
279137db389SSteve Priceoperations, and tells
2801dcc6ec7SPhilippe Charnier.Nm
281137db389SSteve Priceto output the result of the operation without updating the user or group
282137db389SSteve Pricedatabases.
2839fd0dafcSJoerg WunschYou may use the
2849fd0dafcSJoerg Wunsch.Fl P
2859fd0dafcSJoerg Wunschoption to switch between standard passwd and readable formats.
286f1d684faSDavid Nugent.It Fl Y
287f1d684faSDavid NugentUsing this option with any of the update modes causes
2881dcc6ec7SPhilippe Charnier.Nm
289f1d684faSDavid Nugentto run
290f1d684faSDavid Nugent.Xr make 1
291f1d684faSDavid Nugentafter changing to the directory
292f1d684faSDavid Nugent.Pa /var/yp .
293490d5836SPhilippe CharnierThis is intended to allow automatic updating of
294490d5836SPhilippe Charnier.Tn NIS
295490d5836SPhilippe Charnierdatabase files.
296490d5836SPhilippe CharnierIf separate passwd and group files are being used by
297490d5836SPhilippe Charnier.Tn NIS ,
298490d5836SPhilippe Charnierthen use the
299feb04c7bSMateusz Piotrowski.Fl y Ar nispasswd
300490d5836SPhilippe Charnieroption to specify the location of the
301490d5836SPhilippe Charnier.Tn NIS
302490d5836SPhilippe Charnierpasswd database so that
303137db389SSteve Price.Nm
304137db389SSteve Pricewill concurrently update it with the system password
305f1d684faSDavid Nugentdatabases.
306d6f907dcSJoerg Wunsch.El
307d6f907dcSJoerg Wunsch.Sh USER OPTIONS
308d6f907dcSJoerg WunschThe following options apply to the
30977fd0356SMateusz Piotrowski.Cm useradd
310d6f907dcSJoerg Wunschand
31177fd0356SMateusz Piotrowski.Cm usermod
312d6f907dcSJoerg Wunschcommands:
3139fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
3141e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name
3151e4d5cf1SDevin TeskeRequired unless
3161e4d5cf1SDevin Teske.Fl u Ar uid
3171e4d5cf1SDevin Teskeis given.
3181dcc6ec7SPhilippe CharnierSpecify the user/account name.
3191e4d5cf1SDevin TeskeIn the case of
32077fd0356SMateusz Piotrowski.Cm usermod
32177fd0356SMateusz Piotrowskican be a
32277fd0356SMateusz Piotrowski.Ar uid .
323d6f907dcSJoerg Wunsch.It Fl u Ar uid
3241e4d5cf1SDevin TeskeRequired if
3251e4d5cf1SDevin Teske.Ar name
3261e4d5cf1SDevin Teskeis not given.
3271dcc6ec7SPhilippe CharnierSpecify the user/account numeric id.
3281e4d5cf1SDevin TeskeIn the case of
32977fd0356SMateusz Piotrowski.Cm usermod
3301e4d5cf1SDevin Teskeif paired with
3311e4d5cf1SDevin Teske.Ar name ,
3321e4d5cf1SDevin Teskechanges the numeric id of the named user/account.
333d6f907dcSJoerg Wunsch.Pp
3341e4d5cf1SDevin TeskeUsually, only one of these options is required,
3351e4d5cf1SDevin Teskeas the account name will imply the uid, or vice versa.
3361e4d5cf1SDevin TeskeHowever, there are times when both are needed.
337d6f907dcSJoerg WunschFor example, when changing the uid of an existing user with
33877fd0356SMateusz Piotrowski.Cm usermod ,
3391e4d5cf1SDevin Teskeor overriding the default uid when creating a new account with
34077fd0356SMateusz Piotrowski.Cm useradd .
3411e4d5cf1SDevin TeskeTo automatically allocate the uid to a new user with
34277fd0356SMateusz Piotrowski.Cm useradd ,
3431e4d5cf1SDevin Teskethen do
344d6f907dcSJoerg Wunsch.Em not
345d6f907dcSJoerg Wunschuse the
34608657612SRuslan Ermilov.Fl u
3479fd0dafcSJoerg Wunschoption.
3481e4d5cf1SDevin TeskeEither the account or userid can also be provided immediately after the
34977fd0356SMateusz Piotrowski.Cm useradd ,
35077fd0356SMateusz Piotrowski.Cm userdel ,
35177fd0356SMateusz Piotrowski.Cm usermod ,
352137db389SSteve Priceor
35377fd0356SMateusz Piotrowski.Cm usershow
354137db389SSteve Pricekeywords on the command line without using the
35508657612SRuslan Ermilov.Fl n
356137db389SSteve Priceor
35708657612SRuslan Ermilov.Fl u
358137db389SSteve Priceoptions.
359d6f907dcSJoerg Wunsch.El
360d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
361d6f907dcSJoerg Wunsch.It Fl c Ar comment
3621e4d5cf1SDevin TeskeThis field sets the contents of the passwd GECOS field,
3631e4d5cf1SDevin Teskewhich normally contains up to four comma-separated fields containing the
3641e4d5cf1SDevin Teskeuser's full name, office or location,
365137db389SSteve Priceand work and home phone numbers.
366d6f907dcSJoerg WunschThese sub-fields are used by convention only, however, and are optional.
3671e4d5cf1SDevin TeskeIf this field is to contain spaces,
3681e4d5cf1SDevin Teskethe comment must be enclosed in double quotes
369d6f907dcSJoerg Wunsch.Ql \&" .
3701e4d5cf1SDevin TeskeAvoid using commas in this field as these are used as sub-field separators,
3711e4d5cf1SDevin Teskeand the colon
372d6f907dcSJoerg Wunsch.Ql \&:
373137db389SSteve Pricecharacter also cannot be used as this is the field separator for the passwd
374137db389SSteve Pricefile itself.
375feb04c7bSMateusz Piotrowski.It Fl d Ar homedir
376d6f907dcSJoerg WunschThis option sets the account's home directory.
3771e4d5cf1SDevin TeskeNormally,
3781e4d5cf1SDevin Teskethis is only used if the home directory is to be different from the
379137db389SSteve Pricedefault determined from
380137db389SSteve Price.Pa /etc/pw.conf
3811dcc6ec7SPhilippe Charnier- normally
3821dcc6ec7SPhilippe Charnier.Pa /home
383137db389SSteve Pricewith the account name as a subdirectory.
384feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdate
3851dcc6ec7SPhilippe CharnierSet the account's expiration date.
386d6f907dcSJoerg WunschFormat of the date is either a UNIX time in decimal, or a date in
387137db389SSteve Price.Ql dd-mmm-yy[yy]
3881e4d5cf1SDevin Teskeformat, where dd is the day,
3891e4d5cf1SDevin Teskemmm is the month, either in numeric or alphabetic format
3901dcc6ec7SPhilippe Charnier('Jan', 'Feb', etc) and year is either a two or four digit year.
391d6f907dcSJoerg WunschThis option also accepts a relative date in the form
392d6f907dcSJoerg Wunsch.Ql \&+n[mhdwoy]
393d6f907dcSJoerg Wunschwhere
394d6f907dcSJoerg Wunsch.Ql \&n
3951e4d5cf1SDevin Teskeis a decimal,
3961e4d5cf1SDevin Teskeoctal (leading 0) or hexadecimal (leading 0x) digit followed by the
397053375e8SMike Pritchardnumber of Minutes, Hours, Days, Weeks, Months or Years from the current date at
398137db389SSteve Pricewhich the expiration date is to be set.
399feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdate
4001dcc6ec7SPhilippe CharnierSet the account's password expiration date.
401137db389SSteve PriceThis field is similar to the account expiration date option, except that it
402d6f907dcSJoerg Wunschapplies to forced password changes.
403137db389SSteve PriceThis is set in the same manner as the
40408657612SRuslan Ermilov.Fl e
405137db389SSteve Priceoption.
406d6f907dcSJoerg Wunsch.It Fl g Ar group
4071dcc6ec7SPhilippe CharnierSet the account's primary group to the given group.
408d6f907dcSJoerg Wunsch.Ar group
409137db389SSteve Pricemay be defined by either its name or group number.
410d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
411579a636fSWarren BlockSet secondary group memberships for an account.
412d6f907dcSJoerg Wunsch.Ar grouplist
413579a636fSWarren Blockis a comma, space, or tab-separated list of group names or group numbers.
414579a636fSWarren BlockThe user is added to the groups specified in
415579a636fSWarren Block.Ar grouplist ,
416579a636fSWarren Blockand removed from all groups not specified.
417579a636fSWarren BlockThe current login session is not affected by group membership changes,
418579a636fSWarren Blockwhich only take effect when the user reconnects.
419579a636fSWarren BlockNote: do not add a user to their primary group with
420d6f907dcSJoerg Wunsch.Ar grouplist .
4219fd0dafcSJoerg Wunsch.It Fl L Ar class
4229fd0dafcSJoerg WunschThis option sets the login class for the user being created.
4239fd0dafcSJoerg WunschSee
4249fd0dafcSJoerg Wunsch.Xr login.conf 5
42516b4ad52SGiorgos Keramidasand
42616b4ad52SGiorgos Keramidas.Xr passwd 5
427137db389SSteve Pricefor more information on user login classes.
428d6f907dcSJoerg Wunsch.It Fl m
429d6f907dcSJoerg WunschThis option instructs
4301dcc6ec7SPhilippe Charnier.Nm
431d6f907dcSJoerg Wunschto attempt to create the user's home directory.
432d6f907dcSJoerg WunschWhile primarily useful when adding a new account with
43377fd0356SMateusz Piotrowski.Cm useradd ,
4341e4d5cf1SDevin Teskethis may also be of use when moving an existing user's home directory elsewhere
4351e4d5cf1SDevin Teskeon the file system.
436d6f907dcSJoerg WunschThe new home directory is populated with the contents of the
437d6f907dcSJoerg Wunsch.Ar skeleton
438d6f907dcSJoerg Wunschdirectory, which typically contains a set of shell configuration files that the
439053375e8SMike Pritcharduser may personalize to taste.
44031e224ddSTom RhodesFiles in this directory are usually named
441fd59f59aSTom Rhodes.Pa dot . Ns Aq Ar config
44231e224ddSTom Rhodeswhere the
443fd59f59aSTom Rhodes.Pa dot
44431e224ddSTom Rhodesprefix will be stripped.
445d6f907dcSJoerg WunschWhen
44608657612SRuslan Ermilov.Fl m
447d6f907dcSJoerg Wunschis used on an account with
44877fd0356SMateusz Piotrowski.Cm usermod ,
449137db389SSteve Priceexisting configuration files in the user's home directory are
450d6f907dcSJoerg Wunsch.Em not
451137db389SSteve Priceoverwritten from the skeleton files.
452d6f907dcSJoerg Wunsch.Pp
4531e4d5cf1SDevin TeskeWhen a user's home directory is created,
4541e4d5cf1SDevin Teskeit will by default be a subdirectory of the
455d6f907dcSJoerg Wunsch.Ar basehome
456137db389SSteve Pricedirectory as specified by the
45708657612SRuslan Ermilov.Fl b
45877fd0356SMateusz Piotrowskioption, bearing the name of the new account.
459137db389SSteve PriceThis can be overridden by the
46008657612SRuslan Ermilov.Fl d
461d6f907dcSJoerg Wunschoption on the command line, if desired.
462eebbeceeSLukas Ertl.It Fl M Ar mode
463eebbeceeSLukas ErtlCreate the user's home directory with the specified
46485204142SLukas Ertl.Ar mode ,
46585204142SLukas Ertlmodified by the current
46685204142SLukas Ertl.Xr umask 2 .
467eebbeceeSLukas ErtlIf omitted, it is derived from the parent process'
468eebbeceeSLukas Ertl.Xr umask 2 .
469eebbeceeSLukas ErtlThis option is only useful in combination with the
470eebbeceeSLukas Ertl.Fl m
471eebbeceeSLukas Ertlflag.
472feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir
4731dcc6ec7SPhilippe CharnierSet the
474d6f907dcSJoerg Wunsch.Ar skeleton
475137db389SSteve Pricedirectory, from which basic startup and configuration files are copied when
476d6f907dcSJoerg Wunschthe user's home directory is created.
477137db389SSteve PriceThis option only has meaning when used with the
47808657612SRuslan Ermilov.Fl d
479137db389SSteve Priceor
48008657612SRuslan Ermilov.Fl m
481137db389SSteve Priceflags.
482d6f907dcSJoerg Wunsch.It Fl s Ar shell
4831dcc6ec7SPhilippe CharnierSet or changes the user's login shell to
484d6f907dcSJoerg Wunsch.Ar shell .
485d6f907dcSJoerg WunschIf the path to the shell program is omitted,
4861dcc6ec7SPhilippe Charnier.Nm
487d6f907dcSJoerg Wunschsearches the
488d6f907dcSJoerg Wunsch.Ar shellpath
489d6f907dcSJoerg Wunschspecified in
490d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
491d6f907dcSJoerg Wunschand fills it in as appropriate.
492d6f907dcSJoerg WunschNote that unless you have a specific reason to do so, you should avoid
493d6f907dcSJoerg Wunschspecifying the path - this will allow
4941dcc6ec7SPhilippe Charnier.Nm
495d6f907dcSJoerg Wunschto validate that the program exists and is executable.
496d6f907dcSJoerg WunschSpecifying a full path (or supplying a blank "" shell) avoids this check
497d6f907dcSJoerg Wunschand allows for such entries as
4981dcc6ec7SPhilippe Charnier.Pa /nonexistent
499d6f907dcSJoerg Wunschthat should be set for accounts not intended for interactive login.
500d6f907dcSJoerg Wunsch.It Fl h Ar fd
501d6f907dcSJoerg WunschThis option provides a special interface by which interactive scripts can
502d6f907dcSJoerg Wunschset an account password using
503e97407b4SRuslan Ermilov.Nm .
504137db389SSteve PriceBecause the command line and environment are fundamentally insecure mechanisms
505d6f907dcSJoerg Wunschby which programs can accept information,
5061dcc6ec7SPhilippe Charnier.Nm
507d6f907dcSJoerg Wunschwill only allow setting of account and group passwords via a file descriptor
508d6f907dcSJoerg Wunsch(usually a pipe between an interactive script and the program).
509d6f907dcSJoerg Wunsch.Ar sh ,
510d6f907dcSJoerg Wunsch.Ar bash ,
511d6f907dcSJoerg Wunsch.Ar ksh
512d6f907dcSJoerg Wunschand
513d6f907dcSJoerg Wunsch.Ar perl
514137db389SSteve Priceall possess mechanisms by which this can be done.
515d6f907dcSJoerg WunschAlternatively,
516325970a9SPhilippe Charnier.Nm
517d6f907dcSJoerg Wunschwill prompt for the user's password if
51808657612SRuslan Ermilov.Fl h Ar 0
519d6f907dcSJoerg Wunschis given, nominating
520d6f907dcSJoerg Wunsch.Em stdin
521d6f907dcSJoerg Wunschas the file descriptor on which to read the password.
522137db389SSteve PriceNote that this password will be read only once and is intended
523137db389SSteve Pricefor use by a script rather than for interactive use.
524d6f907dcSJoerg WunschIf you wish to have new password confirmation along the lines of
525d6f907dcSJoerg Wunsch.Xr passwd 1 ,
526137db389SSteve Pricethis must be implemented as part of an interactive script that calls
527e97407b4SRuslan Ermilov.Nm .
528d6f907dcSJoerg Wunsch.Pp
529d6f907dcSJoerg WunschIf a value of
530d6f907dcSJoerg Wunsch.Ql \&-
531d6f907dcSJoerg Wunschis given as the argument
532d6f907dcSJoerg Wunsch.Ar fd ,
533d6f907dcSJoerg Wunschthen the password will be set to
534d6f907dcSJoerg Wunsch.Ql \&* ,
535137db389SSteve Pricerendering the account inaccessible via password-based login.
53687d6b5caSIan Dowse.It Fl H Ar fd
53787d6b5caSIan DowseRead an encrypted password string from the specified file descriptor.
53887d6b5caSIan DowseThis is like
53987d6b5caSIan Dowse.Fl h ,
54087d6b5caSIan Dowsebut the password should be supplied already encrypted in a form
54187d6b5caSIan Dowsesuitable for writing directly to the password database.
542adf9cd56SMateusz PiotrowskiSee
543adf9cd56SMateusz Piotrowski.Xr openssl-passwd 1
544adf9cd56SMateusz Piotrowskiand
545adf9cd56SMateusz Piotrowski.Xr crypt 3
546adf9cd56SMateusz Piotrowskifor more details about generating an encrypted password hash.
547d6f907dcSJoerg Wunsch.El
548d6f907dcSJoerg Wunsch.Pp
549d6f907dcSJoerg WunschIt is possible to use
55077fd0356SMateusz Piotrowski.Cm useradd
551d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id.
552d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the
55308657612SRuslan Ermilov.Fl o
5549fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of
5559fd0dafcSJoerg Wunschthe user id.
5569fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under
5579fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home
5589fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same
5599fd0dafcSJoerg Wunschpermissions for access to the user's files in each account.
560d6f907dcSJoerg Wunsch.Pp
561d6f907dcSJoerg WunschThe
56277fd0356SMateusz Piotrowski.Cm useradd
563d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the
56408657612SRuslan Ermilov.Fl D
5659fd0dafcSJoerg Wunschoption.
566d6f907dcSJoerg WunschInstead of adding a new user,
5671dcc6ec7SPhilippe Charnier.Nm
568d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file,
569d6f907dcSJoerg Wunsch.Pa /etc/pw.conf .
570d6f907dcSJoerg WunschWhen using the
57108657612SRuslan Ermilov.Fl D
5729fd0dafcSJoerg Wunschoption, you must not use either
57308657612SRuslan Ermilov.Fl n Ar name
574d6f907dcSJoerg Wunschor
57508657612SRuslan Ermilov.Fl u Ar uid
576d6f907dcSJoerg Wunschor an error will result.
577d6f907dcSJoerg WunschUse of
57808657612SRuslan Ermilov.Fl D
5799fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the
580d6f907dcSJoerg Wunsch.Ar useradd
581d6f907dcSJoerg Wunschcommand.
582d6f907dcSJoerg WunschThese are:
583d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist"
584d6f907dcSJoerg Wunsch.It Fl D
585d6f907dcSJoerg WunschSet default values in
586d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
587d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the
58808657612SRuslan Ermilov.Fl C Ar config
5899fd0dafcSJoerg Wunschoption is used.
590feb04c7bSMateusz Piotrowski.It Fl b Ar basehome
5911dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created.
592d6f907dcSJoerg WunschThe default value for this is
5931dcc6ec7SPhilippe Charnier.Pa /home ,
594d6f907dcSJoerg Wunschbut it may be set elsewhere as desired.
595feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdays
5961dcc6ec7SPhilippe CharnierSet the default account expiration period in days.
5971e4d5cf1SDevin TeskeWhen
5981e4d5cf1SDevin Teske.Fl D
5991e4d5cf1SDevin Teskeis used, the
600feb04c7bSMateusz Piotrowski.Ar accexpdays
6011e4d5cf1SDevin Teskeargument is interpreted differently.
6021e4d5cf1SDevin TeskeIt must be numeric and represents the number of days after creation
6031e4d5cf1SDevin Teskethat the account expires.
604d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date.
605feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdays
6061dcc6ec7SPhilippe CharnierSet the default password expiration period in days.
607d30f122fSEugene GrosbeinWhen
608d30f122fSEugene Grosbein.Fl D
609d30f122fSEugene Grosbeinis used, the
610feb04c7bSMateusz Piotrowski.Ar passexpdays
611d30f122fSEugene Grosbeinargument is interpreted differently.
612d30f122fSEugene GrosbeinIt must be numeric and represents the number of days after creation
613d30f122fSEugene Grosbeinthat the account expires.
614d30f122fSEugene GrosbeinA value of 0 suppresses automatic calculation of the expiry date.
615d6f907dcSJoerg Wunsch.It Fl g Ar group
6161dcc6ec7SPhilippe CharnierSet the default group for new users.
617d6f907dcSJoerg WunschIf a blank group is specified using
61808657612SRuslan Ermilov.Fl g Ar \&"" ,
619137db389SSteve Pricethen new users will be allocated their own private primary group
620137db389SSteve Pricewith the same name as their login name.
621d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument.
622d6f907dcSJoerg Wunsch.It Fl G Ar grouplist
623137db389SSteve PriceSet the default groups in which new users are granted membership.
6241e4d5cf1SDevin TeskeThis is a separate set of groups from the primary group.
6251e4d5cf1SDevin TeskeAvoid nominating the same group as both primary and extra groups.
626d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups
627d6f907dcSJoerg Wunsch.Em other than
628d6f907dcSJoerg Wunschthe primary group.
629d6f907dcSJoerg Wunsch.Ar grouplist
630137db389SSteve Priceis a comma-separated list of group names or ids, and are always
631d6f907dcSJoerg Wunschstored in
632d6f907dcSJoerg Wunsch.Pa /etc/pw.conf
633d6f907dcSJoerg Wunschby their symbolic names.
6349fd0dafcSJoerg Wunsch.It Fl L Ar class
6359fd0dafcSJoerg WunschThis option sets the default login class for new users.
636feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir
6371dcc6ec7SPhilippe CharnierSet the default
638d6f907dcSJoerg Wunsch.Em skeleton
6391e4d5cf1SDevin Teskedirectory,
6401e4d5cf1SDevin Teskefrom which prototype shell and other initialization files are copied when
6411dcc6ec7SPhilippe Charnier.Nm
642d6f907dcSJoerg Wunschcreates a user's home directory.
64331e224ddSTom RhodesSee description of
64431e224ddSTom Rhodes.Fl k
64531e224ddSTom Rhodesfor naming conventions of these files.
646610a5778SRuslan Ermilov.It Xo
647feb04c7bSMateusz Piotrowski.Fl u Ar minuid Ns Cm \&, Ns Ar maxuid ,
648feb04c7bSMateusz Piotrowski.Fl i Ar mingid Ns Cm \&, Ns Ar maxgid
649610a5778SRuslan Ermilov.Xc
6501e4d5cf1SDevin TeskeSet the minimum and maximum user and group ids allocated for new
6511e4d5cf1SDevin Teskeaccounts and groups created by
652e97407b4SRuslan Ermilov.Nm .
653d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum.
654feb04c7bSMateusz Piotrowski.Ar minuid
655d6f907dcSJoerg Wunschand
656feb04c7bSMateusz Piotrowski.Ar maxuid
6571e4d5cf1SDevin Teskeare both numbers, where max must be greater than min,
658feb04c7bSMateusz Piotrowskiand both must be between 0 and 32767
659feb04c7bSMateusz Piotrowski.Po the same applies to
660feb04c7bSMateusz Piotrowski.Ar mingid
661feb04c7bSMateusz Piotrowskiand
662feb04c7bSMateusz Piotrowski.Ar maxgid
663feb04c7bSMateusz Piotrowski.Pc .
6641e4d5cf1SDevin TeskeIn general,
6651e4d5cf1SDevin Teskeuser and group ids less than 100 are reserved for use by the system,
6661e4d5cf1SDevin Teskeand numbers greater than 32000 may also be reserved for special purposes
6671e4d5cf1SDevin Teske.Pq used by some system daemons .
668feb04c7bSMateusz Piotrowski.It Fl w Ar passmethod
669d6f907dcSJoerg WunschThe
67008657612SRuslan Ermilov.Fl w
6711e4d5cf1SDevin Teskeoption selects the default method used to set passwords for newly created user
6721e4d5cf1SDevin Teskeaccounts.
673feb04c7bSMateusz Piotrowski.Ar passmethod
674d6f907dcSJoerg Wunschis one of:
675d6f907dcSJoerg Wunsch.Pp
676d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact
67777fd0356SMateusz Piotrowski.It Cm no
6781dcc6ec7SPhilippe Charnierdisable login on newly created accounts
67977fd0356SMateusz Piotrowski.It Cm yes
6801dcc6ec7SPhilippe Charnierforce the password to be the account name
68177fd0356SMateusz Piotrowski.It Cm none
6821dcc6ec7SPhilippe Charnierforce a blank password
68377fd0356SMateusz Piotrowski.It Cm random
6841dcc6ec7SPhilippe Charniergenerate a random password
685d6f907dcSJoerg Wunsch.El
686d6f907dcSJoerg Wunsch.Pp
687d6f907dcSJoerg WunschThe
68877fd0356SMateusz Piotrowski.Cm random
689d6f907dcSJoerg Wunschor
69077fd0356SMateusz Piotrowski.Cm no
691d6f907dcSJoerg Wunschmethods are the most secure; in the former case,
6921dcc6ec7SPhilippe Charnier.Nm
6931e4d5cf1SDevin Teskegenerates a password and prints it to stdout,
6941e4d5cf1SDevin Teskewhich is suitable when users are issued passwords rather than being allowed
6951e4d5cf1SDevin Tesketo select their own
6961e4d5cf1SDevin Teske.Pq possibly poorly chosen
6971e4d5cf1SDevin Teskepassword.
698d6f907dcSJoerg WunschThe
69977fd0356SMateusz Piotrowski.Cm no
700d6f907dcSJoerg Wunschmethod requires that the superuser use
701d6f907dcSJoerg Wunsch.Xr passwd 1
702d6f907dcSJoerg Wunschto render the account accessible with a password.
703f1d684faSDavid Nugent.It Fl y Ar path
704490d5836SPhilippe CharnierThis sets the pathname of the database used by
705490d5836SPhilippe Charnier.Tn NIS
706490d5836SPhilippe Charnierif you are not sharing
707f1d684faSDavid Nugentthe information from
708f1d684faSDavid Nugent.Pa /etc/master.passwd
709490d5836SPhilippe Charnierdirectly with
710490d5836SPhilippe Charnier.Tn NIS .
711490d5836SPhilippe CharnierYou should only set this option for
712490d5836SPhilippe Charnier.Tn NIS
713490d5836SPhilippe Charnierservers.
714d6f907dcSJoerg Wunsch.El
715d6f907dcSJoerg Wunsch.Pp
716d6f907dcSJoerg WunschThe
71777fd0356SMateusz Piotrowski.Cm userdel
7181e4d5cf1SDevin Teskecommand has three distinct options.
719f2e366a1SSheldon HearnThe
72008657612SRuslan Ermilov.Fl n Ar name
721d6f907dcSJoerg Wunschand
72208657612SRuslan Ermilov.Fl u Ar uid
7239fd0dafcSJoerg Wunschoptions have already been covered above.
7249fd0dafcSJoerg WunschThe additional option is:
7259fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist"
726d6f907dcSJoerg Wunsch.It Fl r
727d6f907dcSJoerg WunschThis tells
7281dcc6ec7SPhilippe Charnier.Nm
729d6f907dcSJoerg Wunschto remove the user's home directory and all of its contents.
730490d5836SPhilippe CharnierThe
731490d5836SPhilippe Charnier.Nm
732490d5836SPhilippe Charnierutility errs on the side of caution when removing files from the system.
7331e4d5cf1SDevin TeskeFirstly,
7341e4d5cf1SDevin Teskeit will not do so if the uid of the account being removed is also used by
73577fd0356SMateusz Piotrowskianother account on the system, and the
73677fd0356SMateusz Piotrowski.Dq home
73777fd0356SMateusz Piotrowskidirectory in the password file is
738d6f907dcSJoerg Wunscha valid path that commences with the character
739d6f907dcSJoerg Wunsch.Ql \&/ .
740d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by
741d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory.
742d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories
743d6f907dcSJoerg Wunschwill be removed.
744d2f1f71eSMike KarelsIf the home directory is a ZFS dataset and has been emptied,
745d2f1f71eSMike Karelsthe dataset will be destroyed.
746d2f1f71eSMike KarelsZFS datasets within the home directory and snapshots are not handled.
747053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator.
748d6f907dcSJoerg Wunsch.El
749d6f907dcSJoerg Wunsch.Pp
75077fd0356SMateusz PiotrowskiMail spool files and
75177fd0356SMateusz Piotrowski.Xr crontab 5
75277fd0356SMateusz Piotrowskifiles are always removed when an account is deleted as
7531e4d5cf1SDevin Teskethese are unconditionally attached to the user name.
754d6f907dcSJoerg WunschJobs queued for processing by
75577fd0356SMateusz Piotrowski.Xr at 1
7561e4d5cf1SDevin Teskeare also removed if the user's uid is unique and not also used by another
7571e4d5cf1SDevin Teskeaccount on the system.
758d6f907dcSJoerg Wunsch.Pp
759d6f907dcSJoerg WunschThe
76077fd0356SMateusz Piotrowski.Cm usermod
76119e1bf29SEitan Adlercommand adds one additional option:
76219e1bf29SEitan Adler.Bl -tag -width "-G grouplist"
7631e4d5cf1SDevin Teske.It Fl l Ar newname
76419e1bf29SEitan AdlerThis option allows changing of an existing account name to
76577fd0356SMateusz Piotrowski.Ar newname .
76619e1bf29SEitan AdlerThe new name must not already exist, and any attempt to duplicate an
76719e1bf29SEitan Adlerexisting account name will be rejected.
76819e1bf29SEitan Adler.El
76919e1bf29SEitan Adler.Pp
77019e1bf29SEitan AdlerThe
77177fd0356SMateusz Piotrowski.Cm usershow
772d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats.
773d6f907dcSJoerg WunschBy default, the format is identical to the format used in
774d6f907dcSJoerg Wunsch.Pa /etc/master.passwd
775d6f907dcSJoerg Wunschwith the password field replaced with a
776d6f907dcSJoerg Wunsch.Ql \&* .
777d6f907dcSJoerg WunschIf the
77808657612SRuslan Ermilov.Fl P
7799fd0dafcSJoerg Wunschoption is used, then
7801dcc6ec7SPhilippe Charnier.Nm
781d6f907dcSJoerg Wunschoutputs the account details in a more human readable form.
7824731d076SDima DorfmanIf the
7834731d076SDima Dorfman.Fl 7
7844731d076SDima Dorfmanoption is used, the account details are shown in v7 format.
785d6f907dcSJoerg WunschThe
78608657612SRuslan Ermilov.Fl a
7879fd0dafcSJoerg Wunschoption lists all users currently on file.
788466c257cSDima DorfmanUsing
789466c257cSDima Dorfman.Fl F
790466c257cSDima Dorfmanforces
791466c257cSDima Dorfman.Nm
792466c257cSDima Dorfmanto print the details of an account even if it does not exist.
7939fd0dafcSJoerg Wunsch.Pp
7949fd0dafcSJoerg WunschThe command
79577fd0356SMateusz Piotrowski.Cm usernext
7969fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon.
7979fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends
7989fd0dafcSJoerg Wunschthat use
799e97407b4SRuslan Ermilov.Nm .
800d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS
801d6f907dcSJoerg WunschThe
80208657612SRuslan Ermilov.Fl C
803d6f907dcSJoerg Wunschand
80408657612SRuslan Ermilov.Fl q
8059fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available
8069fd0dafcSJoerg Wunschwith the group manipulation commands.
807d6f907dcSJoerg WunschOther common options to all group-related commands are:
8089fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8091e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name
8101e4d5cf1SDevin TeskeRequired unless
8111e4d5cf1SDevin Teske.Fl g Ar gid
8121e4d5cf1SDevin Teskeis given.
8131dcc6ec7SPhilippe CharnierSpecify the group name.
8141e4d5cf1SDevin TeskeIn the case of
81577fd0356SMateusz Piotrowski.Cm groupmod
8161e4d5cf1SDevin Teskecan be a gid.
817d6f907dcSJoerg Wunsch.It Fl g Ar gid
8181e4d5cf1SDevin TeskeRequired if
8191e4d5cf1SDevin Teske.Ar name
8201e4d5cf1SDevin Teskeis not given.
8211dcc6ec7SPhilippe CharnierSpecify the group numeric id.
8221e4d5cf1SDevin TeskeIn the case of
82377fd0356SMateusz Piotrowski.Cm groupmod
8241e4d5cf1SDevin Teskeif paired with
8251e4d5cf1SDevin Teske.Ar name ,
8261e4d5cf1SDevin Teskechanges the numeric id of the named group.
827d6f907dcSJoerg Wunsch.Pp
8289fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need
8299fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice
8309fd0dafcSJoerg Wunschversa.
8319fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id
8329fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group.
8337ecd7a42SJoseph Koshy.It Fl M Ar memberlist
8349fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a
83577fd0356SMateusz Piotrowskinew group
83677fd0356SMateusz Piotrowski.Pq in Cm groupadd
83777fd0356SMateusz Piotrowskior replace an existing membership list
83877fd0356SMateusz Piotrowski.Pq in Cm groupmod .
8399fd0dafcSJoerg Wunsch.Ar memberlist
840*d5732956SJose Luis Duranis a comma, space, or tab-separated list of valid and existing user names or
841*d5732956SJose Luis Duranuids.
8429fd0dafcSJoerg Wunsch.It Fl m Ar newmembers
8439fd0dafcSJoerg WunschSimilar to
84408657612SRuslan Ermilov.Fl M ,
8459fd0dafcSJoerg Wunschthis option allows the
8469fd0dafcSJoerg Wunsch.Em addition
847137db389SSteve Priceof existing users to a group without replacing the existing list of
8489fd0dafcSJoerg Wunschmembers.
849137db389SSteve PriceLogin names or user ids may be used, and duplicate users are
850137db389SSteve Pricesilently eliminated.
851bc991a6dSSean Farley.It Fl d Ar oldmembers
852bc991a6dSSean FarleySimilar to
853bc991a6dSSean Farley.Fl M ,
854bc991a6dSSean Farleythis option allows the
855bc991a6dSSean Farley.Em deletion
856bc991a6dSSean Farleyof existing users from a group without replacing the existing list of
857bc991a6dSSean Farleymembers.
858bc991a6dSSean FarleyLogin names or user ids may be used, and duplicate users are
859bc991a6dSSean Farleysilently eliminated.
860d6f907dcSJoerg Wunsch.El
861d6f907dcSJoerg Wunsch.Pp
86277fd0356SMateusz Piotrowski.Cm groupadd
863d6f907dcSJoerg Wunschalso has a
86408657612SRuslan Ermilov.Fl o
865137db389SSteve Priceoption that allows allocation of an existing group id to a new group.
8661e4d5cf1SDevin TeskeThe default action is to reject an attempt to add a group,
8671e4d5cf1SDevin Teskeand this option overrides the check for duplicate group ids.
868d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id.
869d6f907dcSJoerg Wunsch.Pp
870d6f907dcSJoerg WunschThe
87177fd0356SMateusz Piotrowski.Cm groupmod
872137db389SSteve Pricecommand adds one additional option:
8739fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers"
8741e4d5cf1SDevin Teske.It Fl l Ar newname
875d6f907dcSJoerg WunschThis option allows changing of an existing group name to
87677fd0356SMateusz Piotrowski.Ar newname .
8771e4d5cf1SDevin TeskeThe new name must not already exist,
8781e4d5cf1SDevin Teskeand any attempt to duplicate an existing group
879d6f907dcSJoerg Wunschname will be rejected.
880d6f907dcSJoerg Wunsch.El
881d6f907dcSJoerg Wunsch.Pp
882d6f907dcSJoerg WunschOptions for
88377fd0356SMateusz Piotrowski.Cm groupshow
884d6f907dcSJoerg Wunschare the same as for
88577fd0356SMateusz Piotrowski.Cm usershow ,
886d6f907dcSJoerg Wunschwith the
88708657612SRuslan Ermilov.Fl g Ar gid
888d6f907dcSJoerg Wunschreplacing
88908657612SRuslan Ermilov.Fl u Ar uid
890d6f907dcSJoerg Wunschto specify the group id.
8914731d076SDima DorfmanThe
8924731d076SDima Dorfman.Fl 7
8934731d076SDima Dorfmanoption does not apply to the
89477fd0356SMateusz Piotrowski.Cm groupshow
8954731d076SDima Dorfmancommand.
896d6f907dcSJoerg Wunsch.Pp
8979fd0dafcSJoerg WunschThe command
89877fd0356SMateusz Piotrowski.Cm groupnext
8999fd0dafcSJoerg Wunschreturns the next available group id on standard output.
900e468afb4SDima Dorfman.Sh USER LOCKING
901490d5836SPhilippe CharnierThe
902490d5836SPhilippe Charnier.Nm
903490d5836SPhilippe Charnierutility
904e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by
905e468afb4SDima Dorfmanprepending the string
906e468afb4SDima Dorfman.Ql *LOCKED*
907e468afb4SDima Dorfmanto the beginning of the password field in
90877fd0356SMateusz Piotrowski.Xr master.passwd 5
909e468afb4SDima Dorfmanto prevent successful authentication.
910e468afb4SDima Dorfman.Pp
911e468afb4SDima DorfmanThe
91277fd0356SMateusz Piotrowski.Cm lock
913e468afb4SDima Dorfmanand
91477fd0356SMateusz Piotrowski.Cm unlock
915e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock,
91607bfccd7SRuslan Ermilovrespectively.
91707bfccd7SRuslan ErmilovThe
91808657612SRuslan Ermilov.Fl V ,
91908657612SRuslan Ermilov.Fl C ,
920e468afb4SDima Dorfmanand
92108657612SRuslan Ermilov.Fl q
922e468afb4SDima Dorfmanoptions as described above are accepted by these commands.
92359a3c79dSRuslan Ermilov.Sh NOTES
92459a3c79dSRuslan ErmilovFor a summary of options available with each command, you can use
92559a3c79dSRuslan Ermilov.Dl pw [command] help
92659a3c79dSRuslan ErmilovFor example,
92759a3c79dSRuslan Ermilov.Dl pw useradd help
92877fd0356SMateusz Piotrowskilists all available options for the
92977fd0356SMateusz Piotrowski.Cm useradd
93077fd0356SMateusz Piotrowskioperation.
93159a3c79dSRuslan Ermilov.Pp
93259a3c79dSRuslan ErmilovThe
93359a3c79dSRuslan Ermilov.Nm
93459a3c79dSRuslan Ermilovutility allows 8-bit characters in the passwd GECOS field (user's full name,
93559a3c79dSRuslan Ermilovoffice, work and home phone number subfields), but disallows them in
93659a3c79dSRuslan Ermilovuser login and group names.
93759a3c79dSRuslan ErmilovUse 8-bit characters with caution, as connection to the Internet will
93859a3c79dSRuslan Ermilovrequire that your mail transport program supports 8BITMIME, and will
93959a3c79dSRuslan Ermilovconvert headers containing 8-bit characters to 7-bit quoted-printable
94059a3c79dSRuslan Ermilovformat.
94159a3c79dSRuslan Ermilov.Xr sendmail 8
94259a3c79dSRuslan Ermilovdoes support this.
94359a3c79dSRuslan ErmilovUse of 8-bit characters in the GECOS field should be used in
94459a3c79dSRuslan Ermilovconjunction with the user's default locale and character set
94559a3c79dSRuslan Ermilovand should not be implemented without their use.
94659a3c79dSRuslan ErmilovUsing 8-bit characters may also affect other
94759a3c79dSRuslan Ermilovprograms that transmit the contents of the GECOS field over the
94859a3c79dSRuslan ErmilovInternet, such as
94959a3c79dSRuslan Ermilov.Xr fingerd 8 ,
95059a3c79dSRuslan Ermilovand a small number of TCP/IP clients, such as IRC, where full names
95159a3c79dSRuslan Ermilovspecified in the passwd file may be used by default.
95259a3c79dSRuslan Ermilov.Pp
95359a3c79dSRuslan ErmilovThe
95459a3c79dSRuslan Ermilov.Nm
95559a3c79dSRuslan Ermilovutility writes a log to the
95659a3c79dSRuslan Ermilov.Pa /var/log/userlog
95759a3c79dSRuslan Ermilovfile when actions such as user or group additions or deletions occur.
95859a3c79dSRuslan ErmilovThe location of this logfile can be changed in
95959a3c79dSRuslan Ermilov.Xr pw.conf 5 .
96059a3c79dSRuslan Ermilov.Sh FILES
96159a3c79dSRuslan Ermilov.Bl -tag -width /etc/master.passwd.new -compact
96259a3c79dSRuslan Ermilov.It Pa /etc/master.passwd
96359a3c79dSRuslan ErmilovThe user database
96459a3c79dSRuslan Ermilov.It Pa /etc/passwd
96559a3c79dSRuslan ErmilovA Version 7 format password file
96659a3c79dSRuslan Ermilov.It Pa /etc/login.conf
96759a3c79dSRuslan ErmilovThe user capabilities database
96859a3c79dSRuslan Ermilov.It Pa /etc/group
96959a3c79dSRuslan ErmilovThe group database
97059a3c79dSRuslan Ermilov.It Pa /etc/pw.conf
97159a3c79dSRuslan ErmilovPw default options file
97259a3c79dSRuslan Ermilov.It Pa /var/log/userlog
97359a3c79dSRuslan ErmilovUser/group modification logfile
97459a3c79dSRuslan Ermilov.El
9759b8a603eSWarren Block.Sh EXAMPLES
9769b8a603eSWarren BlockAdd new user Glurmo Smith (gsmith).
9779b8a603eSWarren BlockA gsmith login group is created if not already present.
9789b8a603eSWarren BlockThe login shell is set to
9799b8a603eSWarren Block.Xr csh 1 .
9809b8a603eSWarren BlockA new home directory at
9819b8a603eSWarren Block.Pa /home/gsmith
9829b8a603eSWarren Blockis created if it does not already exist.
9839b8a603eSWarren BlockFinally, a random password is generated and displayed:
9849b8a603eSWarren Block.Bd -literal -offset indent
98584733f2eSMateusz Piotrowskipw useradd -n gsmith -c "Glurmo Smith" -s csh -m -w random
9869b8a603eSWarren Block.Ed
987bb00e549SWarren Block.Pp
988bb00e549SWarren BlockDelete the gsmith user and their home directory, including contents.
989bb00e549SWarren Block.Bd -literal -offset indent
990bb00e549SWarren Blockpw userdel -n gsmith -r
991bb00e549SWarren Block.Ed
99260c81cf1SBenedict Reuschling.Pp
99360c81cf1SBenedict ReuschlingAdd the existing user jsmith to the wheel group,
99460c81cf1SBenedict Reuschlingin addition to the other groups jsmith is already a member of.
99560c81cf1SBenedict Reuschling.Bd -literal -offset indent
99660c81cf1SBenedict Reuschlingpw groupmod wheel -m jsmith
99760c81cf1SBenedict Reuschling.Ed
9981cbe5012SEugene Grosbein.Pp
9991cbe5012SEugene GrosbeinGenerate random password and show it in both plain text and
10001cbe5012SEugene Grosbeinencrypted form not modifying any database.
10011cbe5012SEugene Grosbein.Bd -literal -offset indent
10021cbe5012SEugene Grosbeinpw usermod nobody -Nw random
10031cbe5012SEugene Grosbein.Ed
1004a866e170SRuslan Ermilov.Sh EXIT STATUS
1005490d5836SPhilippe CharnierThe
1006490d5836SPhilippe Charnier.Nm
1007490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise
1008137db389SSteve Price.Nm
1009137db389SSteve Pricereturns one of the
10109fd0dafcSJoerg Wunschfollowing exit codes defined by
10119fd0dafcSJoerg Wunsch.Xr sysexits 3
10129fd0dafcSJoerg Wunschas follows:
10139fd0dafcSJoerg Wunsch.Bl -tag -width xxxx
10149fd0dafcSJoerg Wunsch.It EX_USAGE
10159fd0dafcSJoerg Wunsch.Bl -bullet -compact
10169fd0dafcSJoerg Wunsch.It
10171dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option).
10189fd0dafcSJoerg Wunsch.El
10199fd0dafcSJoerg Wunsch.It EX_NOPERM
10209fd0dafcSJoerg Wunsch.Bl -bullet -compact
10219fd0dafcSJoerg Wunsch.It
10229fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root.
10239fd0dafcSJoerg Wunsch.El
10249fd0dafcSJoerg Wunsch.It EX_OSERR
10259fd0dafcSJoerg Wunsch.Bl -bullet -compact
10269fd0dafcSJoerg Wunsch.It
10279fd0dafcSJoerg WunschMemory allocation error.
10289fd0dafcSJoerg Wunsch.It
10299fd0dafcSJoerg WunschRead error from password file descriptor.
10309fd0dafcSJoerg Wunsch.El
10319fd0dafcSJoerg Wunsch.It EX_DATAERR
10329fd0dafcSJoerg Wunsch.Bl -bullet -compact
10339fd0dafcSJoerg Wunsch.It
10349fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or
1035137db389SSteve Pricevia the password file descriptor.
10369fd0dafcSJoerg Wunsch.It
10379fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid.
10389fd0dafcSJoerg Wunsch.El
10399fd0dafcSJoerg Wunsch.It EX_OSFILE
10409fd0dafcSJoerg Wunsch.Bl -bullet -compact
10419fd0dafcSJoerg Wunsch.It
10429fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist.
10439fd0dafcSJoerg Wunsch.It
10449fd0dafcSJoerg WunschBase home directory is invalid or does not exist.
10459fd0dafcSJoerg Wunsch.It
1046137db389SSteve PriceInvalid or non-existent shell specified.
10479fd0dafcSJoerg Wunsch.El
10489fd0dafcSJoerg Wunsch.It EX_NOUSER
10499fd0dafcSJoerg Wunsch.Bl -bullet -compact
10509fd0dafcSJoerg Wunsch.It
10519fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist.
10529fd0dafcSJoerg Wunsch.It
1053137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared.
10549fd0dafcSJoerg Wunsch.El
10559fd0dafcSJoerg Wunsch.It EX_SOFTWARE
10569fd0dafcSJoerg Wunsch.Bl -bullet -compact
10579fd0dafcSJoerg Wunsch.It
10589fd0dafcSJoerg WunschNo more group or user ids available within specified range.
10599fd0dafcSJoerg Wunsch.El
10609fd0dafcSJoerg Wunsch.It EX_IOERR
10619fd0dafcSJoerg Wunsch.Bl -bullet -compact
10629fd0dafcSJoerg Wunsch.It
10639fd0dafcSJoerg WunschUnable to rewrite configuration file.
10649fd0dafcSJoerg Wunsch.It
10659fd0dafcSJoerg WunschError updating group or user database files.
10669fd0dafcSJoerg Wunsch.It
10679fd0dafcSJoerg WunschUpdate error for passwd or group database files.
10689fd0dafcSJoerg Wunsch.El
10699fd0dafcSJoerg Wunsch.It EX_CONFIG
10709fd0dafcSJoerg Wunsch.Bl -bullet -compact
10719fd0dafcSJoerg Wunsch.It
10729fd0dafcSJoerg WunschNo base home directory configured.
10739fd0dafcSJoerg Wunsch.El
10749fd0dafcSJoerg Wunsch.El
1075d6f907dcSJoerg Wunsch.Sh SEE ALSO
1076d6f907dcSJoerg Wunsch.Xr chpass 1 ,
1077053375e8SMike Pritchard.Xr passwd 1 ,
1078eebbeceeSLukas Ertl.Xr umask 2 ,
1079d6f907dcSJoerg Wunsch.Xr group 5 ,
1080bfd34a4aSWolfram Schneider.Xr login.conf 5 ,
1081053375e8SMike Pritchard.Xr passwd 5 ,
1082053375e8SMike Pritchard.Xr pw.conf 5 ,
1083d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 ,
1084d2f1f71eSMike Karels.Xr vipw 8 ,
1085d2f1f71eSMike Karels.Xr zfs 8
1086d6f907dcSJoerg Wunsch.Sh HISTORY
1087490d5836SPhilippe CharnierThe
1088490d5836SPhilippe Charnier.Nm
1089490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV
1090d6f907dcSJoerg Wunsch.Em shadow
10919fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to
1092053375e8SMike Pritchardthe
1093053375e8SMike Pritchard.Bx 4.4
10949fd0dafcSJoerg Wunschoperating system, and combines all of the major elements
10959fd0dafcSJoerg Wunschinto a single command.
1096