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*bb00e549SWarren Block.Dd September 12, 2016 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 37d6f907dcSJoerg Wunsch.Ar useradd 381e4d5cf1SDevin Teske.Oo Fl n Oc name Oo Fl u Ar uid Oc 39d6f907dcSJoerg Wunsch.Op Fl C Ar config 40d6f907dcSJoerg Wunsch.Op Fl q 41d6f907dcSJoerg Wunsch.Op Fl c Ar comment 42d6f907dcSJoerg Wunsch.Op Fl d Ar dir 43d6f907dcSJoerg Wunsch.Op Fl e Ar date 44d6f907dcSJoerg Wunsch.Op Fl p Ar date 45d6f907dcSJoerg Wunsch.Op Fl g Ar group 46d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist 47d6f907dcSJoerg Wunsch.Op Fl m 48eebbeceeSLukas Ertl.Op Fl M Ar mode 49d6f907dcSJoerg Wunsch.Op Fl k Ar dir 50f5875822SSADA Kenji.Op Fl w Ar method 51d6f907dcSJoerg Wunsch.Op Fl s Ar shell 52d6f907dcSJoerg Wunsch.Op Fl o 53d6f907dcSJoerg Wunsch.Op Fl L Ar class 5487d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd 559fd0dafcSJoerg Wunsch.Op Fl N 569fd0dafcSJoerg Wunsch.Op Fl P 57f1d684faSDavid Nugent.Op Fl Y 58e97407b4SRuslan Ermilov.Nm 59a5b912ffSGlen Barber.Op Fl R Ar rootdir 605f12594aSDavid Nugent.Op Fl V Ar etcdir 61d6f907dcSJoerg Wunsch.Ar useradd 62f1d684faSDavid Nugent.Fl D 63d6f907dcSJoerg Wunsch.Op Fl C Ar config 64d6f907dcSJoerg Wunsch.Op Fl q 65d6f907dcSJoerg Wunsch.Op Fl b Ar dir 66d6f907dcSJoerg Wunsch.Op Fl e Ar days 67d6f907dcSJoerg Wunsch.Op Fl p Ar days 68d6f907dcSJoerg Wunsch.Op Fl g Ar group 69d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist 70d6f907dcSJoerg Wunsch.Op Fl k Ar dir 7185204142SLukas Ertl.Op Fl M Ar mode 72610a5778SRuslan Ermilov.Op Fl u Ar min , Ns Ar max 73610a5778SRuslan Ermilov.Op Fl i Ar min , Ns Ar max 74d6f907dcSJoerg Wunsch.Op Fl w Ar method 75d6f907dcSJoerg Wunsch.Op Fl s Ar shell 76f1d684faSDavid Nugent.Op Fl y Ar path 77e97407b4SRuslan Ermilov.Nm 78a5b912ffSGlen Barber.Op Fl R Ar rootdir 795f12594aSDavid Nugent.Op Fl V Ar etcdir 80d6f907dcSJoerg Wunsch.Ar userdel 811e4d5cf1SDevin Teske.Oo Fl n Oc name|uid | Fl u Ar uid 82d6f907dcSJoerg Wunsch.Op Fl r 83f1d684faSDavid Nugent.Op Fl Y 84e97407b4SRuslan Ermilov.Nm 85a5b912ffSGlen Barber.Op Fl R Ar rootdir 865f12594aSDavid Nugent.Op Fl V Ar etcdir 87d6f907dcSJoerg Wunsch.Ar usermod 881e4d5cf1SDevin Teske.Oo Fl n Oc name|uid Oo Fl u Ar newuid Oc | Fl u Ar uid 89d6f907dcSJoerg Wunsch.Op Fl C Ar config 90d6f907dcSJoerg Wunsch.Op Fl q 91d6f907dcSJoerg Wunsch.Op Fl c Ar comment 92d6f907dcSJoerg Wunsch.Op Fl d Ar dir 93d6f907dcSJoerg Wunsch.Op Fl e Ar date 94d6f907dcSJoerg Wunsch.Op Fl p Ar date 95d6f907dcSJoerg Wunsch.Op Fl g Ar group 96d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist 971e4d5cf1SDevin Teske.Op Fl l Ar newname 98d6f907dcSJoerg Wunsch.Op Fl m 99eebbeceeSLukas Ertl.Op Fl M Ar mode 100d6f907dcSJoerg Wunsch.Op Fl k Ar dir 1019fd0dafcSJoerg Wunsch.Op Fl w Ar method 102d6f907dcSJoerg Wunsch.Op Fl s Ar shell 103d6f907dcSJoerg Wunsch.Op Fl L Ar class 10487d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd 1059fd0dafcSJoerg Wunsch.Op Fl N 1069fd0dafcSJoerg Wunsch.Op Fl P 107f1d684faSDavid Nugent.Op Fl Y 108e97407b4SRuslan Ermilov.Nm 109a5b912ffSGlen Barber.Op Fl R Ar rootdir 1105f12594aSDavid Nugent.Op Fl V Ar etcdir 111d6f907dcSJoerg Wunsch.Ar usershow 1121e4d5cf1SDevin Teske.Oo Fl n Oc name|uid | Fl u Ar uid 113d6f907dcSJoerg Wunsch.Op Fl F 1149fd0dafcSJoerg Wunsch.Op Fl P 1154731d076SDima Dorfman.Op Fl 7 116d6f907dcSJoerg Wunsch.Op Fl a 117e97407b4SRuslan Ermilov.Nm 118a5b912ffSGlen Barber.Op Fl R Ar rootdir 1195f12594aSDavid Nugent.Op Fl V Ar etcdir 1209fd0dafcSJoerg Wunsch.Ar usernext 1219fd0dafcSJoerg Wunsch.Op Fl C Ar config 1223bfc59e8SBaptiste Daroussin.Op Fl q 123e97407b4SRuslan Ermilov.Nm 124a5b912ffSGlen Barber.Op Fl R Ar rootdir 1255f12594aSDavid Nugent.Op Fl V Ar etcdir 126d6f907dcSJoerg Wunsch.Ar groupadd 1271e4d5cf1SDevin Teske.Oo Fl n Oc name Oo Fl g Ar gid Oc 128d6f907dcSJoerg Wunsch.Op Fl C Ar config 129d6f907dcSJoerg Wunsch.Op Fl q 1309fd0dafcSJoerg Wunsch.Op Fl M Ar members 131d6f907dcSJoerg Wunsch.Op Fl o 13287d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd 1339fd0dafcSJoerg Wunsch.Op Fl N 1349fd0dafcSJoerg Wunsch.Op Fl P 135f1d684faSDavid Nugent.Op Fl Y 136e97407b4SRuslan Ermilov.Nm 137a5b912ffSGlen Barber.Op Fl R Ar rootdir 1385f12594aSDavid Nugent.Op Fl V Ar etcdir 139d6f907dcSJoerg Wunsch.Ar groupdel 1401e4d5cf1SDevin Teske.Oo Fl n Oc name|gid | Fl g Ar gid 141f1d684faSDavid Nugent.Op Fl Y 142e97407b4SRuslan Ermilov.Nm 143a5b912ffSGlen Barber.Op Fl R Ar rootdir 1445f12594aSDavid Nugent.Op Fl V Ar etcdir 145d6f907dcSJoerg Wunsch.Ar groupmod 1461e4d5cf1SDevin Teske.Oo Fl n Oc name|gid Oo Fl g Ar newgid Oc | Fl g Ar gid 147d6f907dcSJoerg Wunsch.Op Fl C Ar config 148d6f907dcSJoerg Wunsch.Op Fl q 1491e4d5cf1SDevin Teske.Op Fl l Ar newname 1509fd0dafcSJoerg Wunsch.Op Fl M Ar members 1519fd0dafcSJoerg Wunsch.Op Fl m Ar newmembers 152bc991a6dSSean Farley.Op Fl d Ar oldmembers 15387d6b5caSIan Dowse.Op Fl h Ar fd | Fl H Ar fd 1549fd0dafcSJoerg Wunsch.Op Fl N 1559fd0dafcSJoerg Wunsch.Op Fl P 156f1d684faSDavid Nugent.Op Fl Y 157e97407b4SRuslan Ermilov.Nm 158a5b912ffSGlen Barber.Op Fl R Ar rootdir 1595f12594aSDavid Nugent.Op Fl V Ar etcdir 160d6f907dcSJoerg Wunsch.Ar groupshow 1611e4d5cf1SDevin Teske.Oo Fl n Oc name|gid | Fl g Ar gid 162d6f907dcSJoerg Wunsch.Op Fl F 1639fd0dafcSJoerg Wunsch.Op Fl P 164d6f907dcSJoerg Wunsch.Op Fl a 165e97407b4SRuslan Ermilov.Nm 166a5b912ffSGlen Barber.Op Fl R Ar rootdir 1675f12594aSDavid Nugent.Op Fl V Ar etcdir 1689fd0dafcSJoerg Wunsch.Ar groupnext 1699fd0dafcSJoerg Wunsch.Op Fl C Ar config 1703bfc59e8SBaptiste Daroussin.Op Fl q 171e468afb4SDima Dorfman.Nm 172a5b912ffSGlen Barber.Op Fl R Ar rootdir 173e468afb4SDima Dorfman.Op Fl V Ar etcdir 174e468afb4SDima Dorfman.Ar lock 1751e4d5cf1SDevin Teske.Oo Fl n Oc name|uid | Fl u Ar uid 176e468afb4SDima Dorfman.Op Fl C Ar config 177e468afb4SDima Dorfman.Op Fl q 178e468afb4SDima Dorfman.Nm 179a5b912ffSGlen Barber.Op Fl R Ar rootdir 180e468afb4SDima Dorfman.Op Fl V Ar etcdir 181e468afb4SDima Dorfman.Ar unlock 1821e4d5cf1SDevin Teske.Oo Fl n Oc name|uid | Fl u Ar uid 183e468afb4SDima Dorfman.Op Fl C Ar config 184e468afb4SDima Dorfman.Op Fl q 185d6f907dcSJoerg Wunsch.Sh DESCRIPTION 186490d5836SPhilippe CharnierThe 187490d5836SPhilippe Charnier.Nm 188490d5836SPhilippe Charnierutility is a command-line based editor for the system 1891dcc6ec7SPhilippe Charnier.Ar user 190d6f907dcSJoerg Wunschand 1911dcc6ec7SPhilippe Charnier.Ar group 1923a7e7077SDaniel O'Callaghanfiles, allowing the superuser an easy to use and standardized way of adding, 193d6f907dcSJoerg Wunschmodifying and removing users and groups. 194d6f907dcSJoerg WunschNote that 1951dcc6ec7SPhilippe Charnier.Nm 196490d5836SPhilippe Charnieronly operates on the local user and group files. 197490d5836SPhilippe Charnier.Tn NIS 198490d5836SPhilippe Charnierusers and groups must be 199490d5836SPhilippe Charniermaintained on the 200490d5836SPhilippe Charnier.Tn NIS 201490d5836SPhilippe Charnierserver. 202490d5836SPhilippe CharnierThe 203490d5836SPhilippe Charnier.Nm 204490d5836SPhilippe Charnierutility handles updating the 205053375e8SMike Pritchard.Pa passwd , 206053375e8SMike Pritchard.Pa master.passwd , 207053375e8SMike Pritchard.Pa group 208053375e8SMike Pritchardand the secure and insecure 209d6f907dcSJoerg Wunschpassword database files, and must be run as root. 210d6f907dcSJoerg Wunsch.Pp 211137db389SSteve PriceThe first one or two keywords provided to 212137db389SSteve Price.Nm 213137db389SSteve Priceon the command line provide the context for the remainder of the arguments. 214137db389SSteve PriceThe keywords 215d6f907dcSJoerg Wunsch.Ar user 216d6f907dcSJoerg Wunschand 217d6f907dcSJoerg Wunsch.Ar group 218137db389SSteve Pricemay be combined with 219d6f907dcSJoerg Wunsch.Ar add , 220d6f907dcSJoerg Wunsch.Ar del , 2219fd0dafcSJoerg Wunsch.Ar mod , 222d6f907dcSJoerg Wunsch.Ar show , 2239fd0dafcSJoerg Wunschor 224137db389SSteve Price.Ar next 2254e86fcacSSheldon Hearnin any order. 2264e86fcacSSheldon Hearn(For example, 227137db389SSteve Price.Ar showuser , 228137db389SSteve Price.Ar usershow , 229610a5778SRuslan Ermilov.Ar show user , 230610a5778SRuslan Ermilovand 231137db389SSteve Price.Ar user show 232137db389SSteve Priceall mean the same thing.) 233137db389SSteve PriceThis flexibility is useful for interactive scripts calling 2341dcc6ec7SPhilippe Charnier.Nm 235137db389SSteve Pricefor user and group database manipulation. 2361e4d5cf1SDevin TeskeFollowing these keywords, 2371e4d5cf1SDevin Teskethe user or group name or numeric id may be optionally specified as an 2381e4d5cf1SDevin Teskealternative to using the 239d6f907dcSJoerg Wunsch.Fl n Ar name , 240d6f907dcSJoerg Wunsch.Fl u Ar uid , 241d6f907dcSJoerg Wunsch.Fl g Ar gid 2429fd0dafcSJoerg Wunschoptions. 243d6f907dcSJoerg Wunsch.Pp 244d5a3b1edSDima DorfmanThe following flags are common to most or all modes of operation: 2459fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist" 246a5b912ffSGlen Barber.It Fl R Ar rootdir 247a5b912ffSGlen BarberSpecifies an alternate root directory within which 248a5b912ffSGlen Barber.Nm 249a5b912ffSGlen Barberwill operate. 250a5b912ffSGlen BarberAny paths specified will be relative to 251a5b912ffSGlen Barber.Va rootdir . 2525f12594aSDavid Nugent.It Fl V Ar etcdir 2531e4d5cf1SDevin TeskeSet an alternate location for the password, group, and configuration files. 2541e4d5cf1SDevin TeskeCan be used to maintain a user/group database in an alternate location. 2555f12594aSDavid NugentIf this switch is specified, the system 2565f12594aSDavid Nugent.Pa /etc/pw.conf 2571e4d5cf1SDevin Teskewill not be sourced for default configuration data, 2581e4d5cf1SDevin Teskebut the file pw.conf in the specified directory will be used instead 2591e4d5cf1SDevin Teske.Pq or none, if it does not exist . 2605f12594aSDavid NugentThe 2615f12594aSDavid Nugent.Fl C 2625f12594aSDavid Nugentflag may be used to override this behaviour. 2635f12594aSDavid NugentAs an exception to the general rule where options must follow the operation 2645f12594aSDavid Nugenttype, the 2655f12594aSDavid Nugent.Fl V 2664369c82dSBaptiste Daroussinflag must be used on the command line before the operation keyword. 267d6f907dcSJoerg Wunsch.It Fl C Ar config 268d6f907dcSJoerg WunschBy default, 2691dcc6ec7SPhilippe Charnier.Nm 270d6f907dcSJoerg Wunschreads the file 271d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 272137db389SSteve Priceto obtain policy information on how new user accounts and groups are to be created. 273137db389SSteve PriceThe 2749fd0dafcSJoerg Wunsch.Fl C 2759fd0dafcSJoerg Wunschoption specifies a different configuration file. 276137db389SSteve PriceWhile most of the contents of the configuration file may be overridden via 277137db389SSteve Pricecommand-line options, it may be more convenient to keep standard information in a 278137db389SSteve Priceconfiguration file. 279d6f907dcSJoerg Wunsch.It Fl q 280d6f907dcSJoerg WunschUse of this option causes 2811dcc6ec7SPhilippe Charnier.Nm 2821e4d5cf1SDevin Tesketo suppress error messages, 2831e4d5cf1SDevin Teskewhich may be useful in interactive environments where it 284d6f907dcSJoerg Wunschis preferable to interpret status codes returned by 2851dcc6ec7SPhilippe Charnier.Nm 286d6f907dcSJoerg Wunschrather than messing up a carefully formatted display. 2879fd0dafcSJoerg Wunsch.It Fl N 288137db389SSteve PriceThis option is available in 289137db389SSteve Price.Ar add 290137db389SSteve Priceand 291137db389SSteve Price.Ar modify 292137db389SSteve Priceoperations, and tells 2931dcc6ec7SPhilippe Charnier.Nm 294137db389SSteve Priceto output the result of the operation without updating the user or group 295137db389SSteve Pricedatabases. 2969fd0dafcSJoerg WunschYou may use the 2979fd0dafcSJoerg Wunsch.Fl P 2989fd0dafcSJoerg Wunschoption to switch between standard passwd and readable formats. 299f1d684faSDavid Nugent.It Fl Y 300f1d684faSDavid NugentUsing this option with any of the update modes causes 3011dcc6ec7SPhilippe Charnier.Nm 302f1d684faSDavid Nugentto run 303f1d684faSDavid Nugent.Xr make 1 304f1d684faSDavid Nugentafter changing to the directory 305f1d684faSDavid Nugent.Pa /var/yp . 306490d5836SPhilippe CharnierThis is intended to allow automatic updating of 307490d5836SPhilippe Charnier.Tn NIS 308490d5836SPhilippe Charnierdatabase files. 309490d5836SPhilippe CharnierIf separate passwd and group files are being used by 310490d5836SPhilippe Charnier.Tn NIS , 311490d5836SPhilippe Charnierthen use the 312f1d684faSDavid Nugent.Fl y Ar path 313490d5836SPhilippe Charnieroption to specify the location of the 314490d5836SPhilippe Charnier.Tn NIS 315490d5836SPhilippe Charnierpasswd database so that 316137db389SSteve Price.Nm 317137db389SSteve Pricewill concurrently update it with the system password 318f1d684faSDavid Nugentdatabases. 319d6f907dcSJoerg Wunsch.El 320d6f907dcSJoerg Wunsch.Sh USER OPTIONS 321d6f907dcSJoerg WunschThe following options apply to the 322137db389SSteve Price.Ar useradd 323d6f907dcSJoerg Wunschand 324137db389SSteve Price.Ar usermod 325d6f907dcSJoerg Wunschcommands: 3269fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist" 3271e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name 3281e4d5cf1SDevin TeskeRequired unless 3291e4d5cf1SDevin Teske.Fl u Ar uid 3301e4d5cf1SDevin Teskeis given. 3311dcc6ec7SPhilippe CharnierSpecify the user/account name. 3321e4d5cf1SDevin TeskeIn the case of 3331e4d5cf1SDevin Teske.Ar usermod 3341e4d5cf1SDevin Teskecan be a uid. 335d6f907dcSJoerg Wunsch.It Fl u Ar uid 3361e4d5cf1SDevin TeskeRequired if 3371e4d5cf1SDevin Teske.Ar name 3381e4d5cf1SDevin Teskeis not given. 3391dcc6ec7SPhilippe CharnierSpecify the user/account numeric id. 3401e4d5cf1SDevin TeskeIn the case of 3411e4d5cf1SDevin Teske.Ar usermod 3421e4d5cf1SDevin Teskeif paired with 3431e4d5cf1SDevin Teske.Ar name , 3441e4d5cf1SDevin Teskechanges the numeric id of the named user/account. 345d6f907dcSJoerg Wunsch.Pp 3461e4d5cf1SDevin TeskeUsually, only one of these options is required, 3471e4d5cf1SDevin Teskeas the account name will imply the uid, or vice versa. 3481e4d5cf1SDevin TeskeHowever, there are times when both are needed. 349d6f907dcSJoerg WunschFor example, when changing the uid of an existing user with 350d6f907dcSJoerg Wunsch.Ar usermod , 3511e4d5cf1SDevin Teskeor overriding the default uid when creating a new account with 3521e4d5cf1SDevin Teske.Ar useradd . 3531e4d5cf1SDevin TeskeTo automatically allocate the uid to a new user with 354d6f907dcSJoerg Wunsch.Ar useradd , 3551e4d5cf1SDevin Teskethen do 356d6f907dcSJoerg Wunsch.Em not 357d6f907dcSJoerg Wunschuse the 35808657612SRuslan Ermilov.Fl u 3599fd0dafcSJoerg Wunschoption. 3601e4d5cf1SDevin TeskeEither the account or userid can also be provided immediately after the 361137db389SSteve Price.Ar useradd , 362137db389SSteve Price.Ar userdel , 363137db389SSteve Price.Ar usermod 364137db389SSteve Priceor 365137db389SSteve Price.Ar usershow 366137db389SSteve Pricekeywords on the command line without using the 36708657612SRuslan Ermilov.Fl n 368137db389SSteve Priceor 36908657612SRuslan Ermilov.Fl u 370137db389SSteve Priceoptions. 371d6f907dcSJoerg Wunsch.El 372d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist" 373d6f907dcSJoerg Wunsch.It Fl c Ar comment 3741e4d5cf1SDevin TeskeThis field sets the contents of the passwd GECOS field, 3751e4d5cf1SDevin Teskewhich normally contains up to four comma-separated fields containing the 3761e4d5cf1SDevin Teskeuser's full name, office or location, 377137db389SSteve Priceand work and home phone numbers. 378d6f907dcSJoerg WunschThese sub-fields are used by convention only, however, and are optional. 3791e4d5cf1SDevin TeskeIf this field is to contain spaces, 3801e4d5cf1SDevin Teskethe comment must be enclosed in double quotes 381d6f907dcSJoerg Wunsch.Ql \&" . 3821e4d5cf1SDevin TeskeAvoid using commas in this field as these are used as sub-field separators, 3831e4d5cf1SDevin Teskeand the colon 384d6f907dcSJoerg Wunsch.Ql \&: 385137db389SSteve Pricecharacter also cannot be used as this is the field separator for the passwd 386137db389SSteve Pricefile itself. 387d6f907dcSJoerg Wunsch.It Fl d Ar dir 388d6f907dcSJoerg WunschThis option sets the account's home directory. 3891e4d5cf1SDevin TeskeNormally, 3901e4d5cf1SDevin Teskethis is only used if the home directory is to be different from the 391137db389SSteve Pricedefault determined from 392137db389SSteve Price.Pa /etc/pw.conf 3931dcc6ec7SPhilippe Charnier- normally 3941dcc6ec7SPhilippe Charnier.Pa /home 395137db389SSteve Pricewith the account name as a subdirectory. 396d6f907dcSJoerg Wunsch.It Fl e Ar date 3971dcc6ec7SPhilippe CharnierSet the account's expiration date. 398d6f907dcSJoerg WunschFormat of the date is either a UNIX time in decimal, or a date in 399137db389SSteve Price.Ql dd-mmm-yy[yy] 4001e4d5cf1SDevin Teskeformat, where dd is the day, 4011e4d5cf1SDevin Teskemmm is the month, either in numeric or alphabetic format 4021dcc6ec7SPhilippe Charnier('Jan', 'Feb', etc) and year is either a two or four digit year. 403d6f907dcSJoerg WunschThis option also accepts a relative date in the form 404d6f907dcSJoerg Wunsch.Ql \&+n[mhdwoy] 405d6f907dcSJoerg Wunschwhere 406d6f907dcSJoerg Wunsch.Ql \&n 4071e4d5cf1SDevin Teskeis a decimal, 4081e4d5cf1SDevin Teskeoctal (leading 0) or hexadecimal (leading 0x) digit followed by the 409053375e8SMike Pritchardnumber of Minutes, Hours, Days, Weeks, Months or Years from the current date at 410137db389SSteve Pricewhich the expiration date is to be set. 411d6f907dcSJoerg Wunsch.It Fl p Ar date 4121dcc6ec7SPhilippe CharnierSet the account's password expiration date. 413137db389SSteve PriceThis field is similar to the account expiration date option, except that it 414d6f907dcSJoerg Wunschapplies to forced password changes. 415137db389SSteve PriceThis is set in the same manner as the 41608657612SRuslan Ermilov.Fl e 417137db389SSteve Priceoption. 418d6f907dcSJoerg Wunsch.It Fl g Ar group 4191dcc6ec7SPhilippe CharnierSet the account's primary group to the given group. 420d6f907dcSJoerg Wunsch.Ar group 421137db389SSteve Pricemay be defined by either its name or group number. 422d6f907dcSJoerg Wunsch.It Fl G Ar grouplist 423579a636fSWarren BlockSet secondary group memberships for an account. 424d6f907dcSJoerg Wunsch.Ar grouplist 425579a636fSWarren Blockis a comma, space, or tab-separated list of group names or group numbers. 426579a636fSWarren BlockThe user is added to the groups specified in 427579a636fSWarren Block.Ar grouplist , 428579a636fSWarren Blockand removed from all groups not specified. 429579a636fSWarren BlockThe current login session is not affected by group membership changes, 430579a636fSWarren Blockwhich only take effect when the user reconnects. 431579a636fSWarren BlockNote: do not add a user to their primary group with 432d6f907dcSJoerg Wunsch.Ar grouplist . 4339fd0dafcSJoerg Wunsch.It Fl L Ar class 4349fd0dafcSJoerg WunschThis option sets the login class for the user being created. 4359fd0dafcSJoerg WunschSee 4369fd0dafcSJoerg Wunsch.Xr login.conf 5 43716b4ad52SGiorgos Keramidasand 43816b4ad52SGiorgos Keramidas.Xr passwd 5 439137db389SSteve Pricefor more information on user login classes. 440d6f907dcSJoerg Wunsch.It Fl m 441d6f907dcSJoerg WunschThis option instructs 4421dcc6ec7SPhilippe Charnier.Nm 443d6f907dcSJoerg Wunschto attempt to create the user's home directory. 444d6f907dcSJoerg WunschWhile primarily useful when adding a new account with 445d6f907dcSJoerg Wunsch.Ar useradd , 4461e4d5cf1SDevin Teskethis may also be of use when moving an existing user's home directory elsewhere 4471e4d5cf1SDevin Teskeon the file system. 448d6f907dcSJoerg WunschThe new home directory is populated with the contents of the 449d6f907dcSJoerg Wunsch.Ar skeleton 450d6f907dcSJoerg Wunschdirectory, which typically contains a set of shell configuration files that the 451053375e8SMike Pritcharduser may personalize to taste. 45231e224ddSTom RhodesFiles in this directory are usually named 453fd59f59aSTom Rhodes.Pa dot . Ns Aq Ar config 45431e224ddSTom Rhodeswhere the 455fd59f59aSTom Rhodes.Pa dot 45631e224ddSTom Rhodesprefix will be stripped. 457d6f907dcSJoerg WunschWhen 45808657612SRuslan Ermilov.Fl m 459d6f907dcSJoerg Wunschis used on an account with 460d6f907dcSJoerg Wunsch.Ar usermod , 461137db389SSteve Priceexisting configuration files in the user's home directory are 462d6f907dcSJoerg Wunsch.Em not 463137db389SSteve Priceoverwritten from the skeleton files. 464d6f907dcSJoerg Wunsch.Pp 4651e4d5cf1SDevin TeskeWhen a user's home directory is created, 4661e4d5cf1SDevin Teskeit will by default be a subdirectory of the 467d6f907dcSJoerg Wunsch.Ar basehome 468137db389SSteve Pricedirectory as specified by the 46908657612SRuslan Ermilov.Fl b 470137db389SSteve Priceoption (see below), bearing the name of the new account. 471137db389SSteve PriceThis can be overridden by the 47208657612SRuslan Ermilov.Fl d 473d6f907dcSJoerg Wunschoption on the command line, if desired. 474eebbeceeSLukas Ertl.It Fl M Ar mode 475eebbeceeSLukas ErtlCreate the user's home directory with the specified 47685204142SLukas Ertl.Ar mode , 47785204142SLukas Ertlmodified by the current 47885204142SLukas Ertl.Xr umask 2 . 479eebbeceeSLukas ErtlIf omitted, it is derived from the parent process' 480eebbeceeSLukas Ertl.Xr umask 2 . 481eebbeceeSLukas ErtlThis option is only useful in combination with the 482eebbeceeSLukas Ertl.Fl m 483eebbeceeSLukas Ertlflag. 484d6f907dcSJoerg Wunsch.It Fl k Ar dir 4851dcc6ec7SPhilippe CharnierSet the 486d6f907dcSJoerg Wunsch.Ar skeleton 487137db389SSteve Pricedirectory, from which basic startup and configuration files are copied when 488d6f907dcSJoerg Wunschthe user's home directory is created. 489137db389SSteve PriceThis option only has meaning when used with the 49008657612SRuslan Ermilov.Fl d 491137db389SSteve Priceor 49208657612SRuslan Ermilov.Fl m 493137db389SSteve Priceflags. 494d6f907dcSJoerg Wunsch.It Fl s Ar shell 4951dcc6ec7SPhilippe CharnierSet or changes the user's login shell to 496d6f907dcSJoerg Wunsch.Ar shell . 497d6f907dcSJoerg WunschIf the path to the shell program is omitted, 4981dcc6ec7SPhilippe Charnier.Nm 499d6f907dcSJoerg Wunschsearches the 500d6f907dcSJoerg Wunsch.Ar shellpath 501d6f907dcSJoerg Wunschspecified in 502d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 503d6f907dcSJoerg Wunschand fills it in as appropriate. 504d6f907dcSJoerg WunschNote that unless you have a specific reason to do so, you should avoid 505d6f907dcSJoerg Wunschspecifying the path - this will allow 5061dcc6ec7SPhilippe Charnier.Nm 507d6f907dcSJoerg Wunschto validate that the program exists and is executable. 508d6f907dcSJoerg WunschSpecifying a full path (or supplying a blank "" shell) avoids this check 509d6f907dcSJoerg Wunschand allows for such entries as 5101dcc6ec7SPhilippe Charnier.Pa /nonexistent 511d6f907dcSJoerg Wunschthat should be set for accounts not intended for interactive login. 512d6f907dcSJoerg Wunsch.It Fl h Ar fd 513d6f907dcSJoerg WunschThis option provides a special interface by which interactive scripts can 514d6f907dcSJoerg Wunschset an account password using 515e97407b4SRuslan Ermilov.Nm . 516137db389SSteve PriceBecause the command line and environment are fundamentally insecure mechanisms 517d6f907dcSJoerg Wunschby which programs can accept information, 5181dcc6ec7SPhilippe Charnier.Nm 519d6f907dcSJoerg Wunschwill only allow setting of account and group passwords via a file descriptor 520d6f907dcSJoerg Wunsch(usually a pipe between an interactive script and the program). 521d6f907dcSJoerg Wunsch.Ar sh , 522d6f907dcSJoerg Wunsch.Ar bash , 523d6f907dcSJoerg Wunsch.Ar ksh 524d6f907dcSJoerg Wunschand 525d6f907dcSJoerg Wunsch.Ar perl 526137db389SSteve Priceall possess mechanisms by which this can be done. 527d6f907dcSJoerg WunschAlternatively, 528325970a9SPhilippe Charnier.Nm 529d6f907dcSJoerg Wunschwill prompt for the user's password if 53008657612SRuslan Ermilov.Fl h Ar 0 531d6f907dcSJoerg Wunschis given, nominating 532d6f907dcSJoerg Wunsch.Em stdin 533d6f907dcSJoerg Wunschas the file descriptor on which to read the password. 534137db389SSteve PriceNote that this password will be read only once and is intended 535137db389SSteve Pricefor use by a script rather than for interactive use. 536d6f907dcSJoerg WunschIf you wish to have new password confirmation along the lines of 537d6f907dcSJoerg Wunsch.Xr passwd 1 , 538137db389SSteve Pricethis must be implemented as part of an interactive script that calls 539e97407b4SRuslan Ermilov.Nm . 540d6f907dcSJoerg Wunsch.Pp 541d6f907dcSJoerg WunschIf a value of 542d6f907dcSJoerg Wunsch.Ql \&- 543d6f907dcSJoerg Wunschis given as the argument 544d6f907dcSJoerg Wunsch.Ar fd , 545d6f907dcSJoerg Wunschthen the password will be set to 546d6f907dcSJoerg Wunsch.Ql \&* , 547137db389SSteve Pricerendering the account inaccessible via password-based login. 54887d6b5caSIan Dowse.It Fl H Ar fd 54987d6b5caSIan DowseRead an encrypted password string from the specified file descriptor. 55087d6b5caSIan DowseThis is like 55187d6b5caSIan Dowse.Fl h , 55287d6b5caSIan Dowsebut the password should be supplied already encrypted in a form 55387d6b5caSIan Dowsesuitable for writing directly to the password database. 554d6f907dcSJoerg Wunsch.El 555d6f907dcSJoerg Wunsch.Pp 556d6f907dcSJoerg WunschIt is possible to use 557d6f907dcSJoerg Wunsch.Ar useradd 558d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id. 559d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the 56008657612SRuslan Ermilov.Fl o 5619fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of 5629fd0dafcSJoerg Wunschthe user id. 5639fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under 5649fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home 5659fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same 5669fd0dafcSJoerg Wunschpermissions for access to the user's files in each account. 567d6f907dcSJoerg Wunsch.Pp 568d6f907dcSJoerg WunschThe 569d6f907dcSJoerg Wunsch.Ar useradd 570d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the 57108657612SRuslan Ermilov.Fl D 5729fd0dafcSJoerg Wunschoption. 573d6f907dcSJoerg WunschInstead of adding a new user, 5741dcc6ec7SPhilippe Charnier.Nm 575d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file, 576d6f907dcSJoerg Wunsch.Pa /etc/pw.conf . 577d6f907dcSJoerg WunschWhen using the 57808657612SRuslan Ermilov.Fl D 5799fd0dafcSJoerg Wunschoption, you must not use either 58008657612SRuslan Ermilov.Fl n Ar name 581d6f907dcSJoerg Wunschor 58208657612SRuslan Ermilov.Fl u Ar uid 583d6f907dcSJoerg Wunschor an error will result. 584d6f907dcSJoerg WunschUse of 58508657612SRuslan Ermilov.Fl D 5869fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the 587d6f907dcSJoerg Wunsch.Ar useradd 588d6f907dcSJoerg Wunschcommand. 589d6f907dcSJoerg WunschThese are: 590d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist" 591d6f907dcSJoerg Wunsch.It Fl D 592d6f907dcSJoerg WunschSet default values in 593d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 594d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the 59508657612SRuslan Ermilov.Fl C Ar config 5969fd0dafcSJoerg Wunschoption is used. 597d6f907dcSJoerg Wunsch.It Fl b Ar dir 5981dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created. 599d6f907dcSJoerg WunschThe default value for this is 6001dcc6ec7SPhilippe Charnier.Pa /home , 601d6f907dcSJoerg Wunschbut it may be set elsewhere as desired. 602d6f907dcSJoerg Wunsch.It Fl e Ar days 6031dcc6ec7SPhilippe CharnierSet the default account expiration period in days. 6041e4d5cf1SDevin TeskeWhen 6051e4d5cf1SDevin Teske.Fl D 6061e4d5cf1SDevin Teskeis used, the 6071e4d5cf1SDevin Teske.Ar days 6081e4d5cf1SDevin Teskeargument is interpreted differently. 6091e4d5cf1SDevin TeskeIt must be numeric and represents the number of days after creation 6101e4d5cf1SDevin Teskethat the account expires. 611d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date. 612d6f907dcSJoerg Wunsch.It Fl p Ar days 6131dcc6ec7SPhilippe CharnierSet the default password expiration period in days. 614d6f907dcSJoerg Wunsch.It Fl g Ar group 6151dcc6ec7SPhilippe CharnierSet the default group for new users. 616d6f907dcSJoerg WunschIf a blank group is specified using 61708657612SRuslan Ermilov.Fl g Ar \&"" , 618137db389SSteve Pricethen new users will be allocated their own private primary group 619137db389SSteve Pricewith the same name as their login name. 620d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument. 621d6f907dcSJoerg Wunsch.It Fl G Ar grouplist 622137db389SSteve PriceSet the default groups in which new users are granted membership. 6231e4d5cf1SDevin TeskeThis is a separate set of groups from the primary group. 6241e4d5cf1SDevin TeskeAvoid nominating the same group as both primary and extra groups. 625d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups 626d6f907dcSJoerg Wunsch.Em other than 627d6f907dcSJoerg Wunschthe primary group. 628d6f907dcSJoerg Wunsch.Ar grouplist 629137db389SSteve Priceis a comma-separated list of group names or ids, and are always 630d6f907dcSJoerg Wunschstored in 631d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 632d6f907dcSJoerg Wunschby their symbolic names. 6339fd0dafcSJoerg Wunsch.It Fl L Ar class 6349fd0dafcSJoerg WunschThis option sets the default login class for new users. 635d6f907dcSJoerg Wunsch.It Fl k Ar dir 6361dcc6ec7SPhilippe CharnierSet the default 637d6f907dcSJoerg Wunsch.Em skeleton 6381e4d5cf1SDevin Teskedirectory, 6391e4d5cf1SDevin Teskefrom which prototype shell and other initialization files are copied when 6401dcc6ec7SPhilippe Charnier.Nm 641d6f907dcSJoerg Wunschcreates a user's home directory. 64231e224ddSTom RhodesSee description of 64331e224ddSTom Rhodes.Fl k 64431e224ddSTom Rhodesfor naming conventions of these files. 645610a5778SRuslan Ermilov.It Xo 646610a5778SRuslan Ermilov.Fl u Ar min , Ns Ar max , 647610a5778SRuslan Ermilov.Fl i Ar min , Ns Ar max 648610a5778SRuslan Ermilov.Xc 6491e4d5cf1SDevin TeskeSet the minimum and maximum user and group ids allocated for new 6501e4d5cf1SDevin Teskeaccounts and groups created by 651e97407b4SRuslan Ermilov.Nm . 652d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum. 653d6f907dcSJoerg Wunsch.Ar min 654d6f907dcSJoerg Wunschand 655d6f907dcSJoerg Wunsch.Ar max 6561e4d5cf1SDevin Teskeare both numbers, where max must be greater than min, 6571e4d5cf1SDevin Teskeand both must be between 0 and 32767. 6581e4d5cf1SDevin TeskeIn general, 6591e4d5cf1SDevin Teskeuser and group ids less than 100 are reserved for use by the system, 6601e4d5cf1SDevin Teskeand numbers greater than 32000 may also be reserved for special purposes 6611e4d5cf1SDevin Teske.Pq used by some system daemons . 662d6f907dcSJoerg Wunsch.It Fl w Ar method 663d6f907dcSJoerg WunschThe 66408657612SRuslan Ermilov.Fl w 6651e4d5cf1SDevin Teskeoption selects the default method used to set passwords for newly created user 6661e4d5cf1SDevin Teskeaccounts. 667d6f907dcSJoerg Wunsch.Ar method 668d6f907dcSJoerg Wunschis one of: 669d6f907dcSJoerg Wunsch.Pp 670d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact 671d6f907dcSJoerg Wunsch.It no 6721dcc6ec7SPhilippe Charnierdisable login on newly created accounts 673d6f907dcSJoerg Wunsch.It yes 6741dcc6ec7SPhilippe Charnierforce the password to be the account name 675d6f907dcSJoerg Wunsch.It none 6761dcc6ec7SPhilippe Charnierforce a blank password 677d6f907dcSJoerg Wunsch.It random 6781dcc6ec7SPhilippe Charniergenerate a random password 679d6f907dcSJoerg Wunsch.El 680d6f907dcSJoerg Wunsch.Pp 681d6f907dcSJoerg WunschThe 682d6f907dcSJoerg Wunsch.Ql \&random 683d6f907dcSJoerg Wunschor 684d6f907dcSJoerg Wunsch.Ql \&no 685d6f907dcSJoerg Wunschmethods are the most secure; in the former case, 6861dcc6ec7SPhilippe Charnier.Nm 6871e4d5cf1SDevin Teskegenerates a password and prints it to stdout, 6881e4d5cf1SDevin Teskewhich is suitable when users are issued passwords rather than being allowed 6891e4d5cf1SDevin Tesketo select their own 6901e4d5cf1SDevin Teske.Pq possibly poorly chosen 6911e4d5cf1SDevin Teskepassword. 692d6f907dcSJoerg WunschThe 693d6f907dcSJoerg Wunsch.Ql \&no 694d6f907dcSJoerg Wunschmethod requires that the superuser use 695d6f907dcSJoerg Wunsch.Xr passwd 1 696d6f907dcSJoerg Wunschto render the account accessible with a password. 697f1d684faSDavid Nugent.It Fl y Ar path 698490d5836SPhilippe CharnierThis sets the pathname of the database used by 699490d5836SPhilippe Charnier.Tn NIS 700490d5836SPhilippe Charnierif you are not sharing 701f1d684faSDavid Nugentthe information from 702f1d684faSDavid Nugent.Pa /etc/master.passwd 703490d5836SPhilippe Charnierdirectly with 704490d5836SPhilippe Charnier.Tn NIS . 705490d5836SPhilippe CharnierYou should only set this option for 706490d5836SPhilippe Charnier.Tn NIS 707490d5836SPhilippe Charnierservers. 708d6f907dcSJoerg Wunsch.El 709d6f907dcSJoerg Wunsch.Pp 710d6f907dcSJoerg WunschThe 711d6f907dcSJoerg Wunsch.Ar userdel 7121e4d5cf1SDevin Teskecommand has three distinct options. 713f2e366a1SSheldon HearnThe 71408657612SRuslan Ermilov.Fl n Ar name 715d6f907dcSJoerg Wunschand 71608657612SRuslan Ermilov.Fl u Ar uid 7179fd0dafcSJoerg Wunschoptions have already been covered above. 7189fd0dafcSJoerg WunschThe additional option is: 7199fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist" 720d6f907dcSJoerg Wunsch.It Fl r 721d6f907dcSJoerg WunschThis tells 7221dcc6ec7SPhilippe Charnier.Nm 723d6f907dcSJoerg Wunschto remove the user's home directory and all of its contents. 724490d5836SPhilippe CharnierThe 725490d5836SPhilippe Charnier.Nm 726490d5836SPhilippe Charnierutility errs on the side of caution when removing files from the system. 7271e4d5cf1SDevin TeskeFirstly, 7281e4d5cf1SDevin Teskeit will not do so if the uid of the account being removed is also used by 729d6f907dcSJoerg Wunschanother account on the system, and the 'home' directory in the password file is 730d6f907dcSJoerg Wunscha valid path that commences with the character 731d6f907dcSJoerg Wunsch.Ql \&/ . 732d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by 733d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory. 734d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories 735d6f907dcSJoerg Wunschwill be removed. 736053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator. 737d6f907dcSJoerg Wunsch.El 738d6f907dcSJoerg Wunsch.Pp 7391e4d5cf1SDevin TeskeMail spool files and crontabs are always removed when an account is deleted as 7401e4d5cf1SDevin Teskethese are unconditionally attached to the user name. 741d6f907dcSJoerg WunschJobs queued for processing by 742d6f907dcSJoerg Wunsch.Ar at 7431e4d5cf1SDevin Teskeare also removed if the user's uid is unique and not also used by another 7441e4d5cf1SDevin Teskeaccount on the system. 745d6f907dcSJoerg Wunsch.Pp 746d6f907dcSJoerg WunschThe 74719e1bf29SEitan Adler.Ar usermod 74819e1bf29SEitan Adlercommand adds one additional option: 74919e1bf29SEitan Adler.Bl -tag -width "-G grouplist" 7501e4d5cf1SDevin Teske.It Fl l Ar newname 75119e1bf29SEitan AdlerThis option allows changing of an existing account name to 7521e4d5cf1SDevin Teske.Ql \&newname . 75319e1bf29SEitan AdlerThe new name must not already exist, and any attempt to duplicate an 75419e1bf29SEitan Adlerexisting account name will be rejected. 75519e1bf29SEitan Adler.El 75619e1bf29SEitan Adler.Pp 75719e1bf29SEitan AdlerThe 758d6f907dcSJoerg Wunsch.Ar usershow 759d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats. 760d6f907dcSJoerg WunschBy default, the format is identical to the format used in 761d6f907dcSJoerg Wunsch.Pa /etc/master.passwd 762d6f907dcSJoerg Wunschwith the password field replaced with a 763d6f907dcSJoerg Wunsch.Ql \&* . 764d6f907dcSJoerg WunschIf the 76508657612SRuslan Ermilov.Fl P 7669fd0dafcSJoerg Wunschoption is used, then 7671dcc6ec7SPhilippe Charnier.Nm 768d6f907dcSJoerg Wunschoutputs the account details in a more human readable form. 7694731d076SDima DorfmanIf the 7704731d076SDima Dorfman.Fl 7 7714731d076SDima Dorfmanoption is used, the account details are shown in v7 format. 772d6f907dcSJoerg WunschThe 77308657612SRuslan Ermilov.Fl a 7749fd0dafcSJoerg Wunschoption lists all users currently on file. 775466c257cSDima DorfmanUsing 776466c257cSDima Dorfman.Fl F 777466c257cSDima Dorfmanforces 778466c257cSDima Dorfman.Nm 779466c257cSDima Dorfmanto print the details of an account even if it does not exist. 7809fd0dafcSJoerg Wunsch.Pp 7819fd0dafcSJoerg WunschThe command 7829fd0dafcSJoerg Wunsch.Ar usernext 7839fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon. 7849fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends 7859fd0dafcSJoerg Wunschthat use 786e97407b4SRuslan Ermilov.Nm . 787d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS 788d6f907dcSJoerg WunschThe 78908657612SRuslan Ermilov.Fl C 790d6f907dcSJoerg Wunschand 79108657612SRuslan Ermilov.Fl q 7929fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available 7939fd0dafcSJoerg Wunschwith the group manipulation commands. 794d6f907dcSJoerg WunschOther common options to all group-related commands are: 7959fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers" 7961e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name 7971e4d5cf1SDevin TeskeRequired unless 7981e4d5cf1SDevin Teske.Fl g Ar gid 7991e4d5cf1SDevin Teskeis given. 8001dcc6ec7SPhilippe CharnierSpecify the group name. 8011e4d5cf1SDevin TeskeIn the case of 8021e4d5cf1SDevin Teske.Ar groupmod 8031e4d5cf1SDevin Teskecan be a gid. 804d6f907dcSJoerg Wunsch.It Fl g Ar gid 8051e4d5cf1SDevin TeskeRequired if 8061e4d5cf1SDevin Teske.Ar name 8071e4d5cf1SDevin Teskeis not given. 8081dcc6ec7SPhilippe CharnierSpecify the group numeric id. 8091e4d5cf1SDevin TeskeIn the case of 8101e4d5cf1SDevin Teske.Ar groupmod 8111e4d5cf1SDevin Teskeif paired with 8121e4d5cf1SDevin Teske.Ar name , 8131e4d5cf1SDevin Teskechanges the numeric id of the named group. 814d6f907dcSJoerg Wunsch.Pp 8159fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need 8169fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice 8179fd0dafcSJoerg Wunschversa. 8189fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id 8199fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group. 8207ecd7a42SJoseph Koshy.It Fl M Ar memberlist 8219fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a 8229fd0dafcSJoerg Wunschnew group (in groupadd) or replace an existing membership list (in 8239fd0dafcSJoerg Wunschgroupmod). 8249fd0dafcSJoerg Wunsch.Ar memberlist 8259fd0dafcSJoerg Wunschis a comma separated list of valid and existing user names or uids. 8269fd0dafcSJoerg Wunsch.It Fl m Ar newmembers 8279fd0dafcSJoerg WunschSimilar to 82808657612SRuslan Ermilov.Fl M , 8299fd0dafcSJoerg Wunschthis option allows the 8309fd0dafcSJoerg Wunsch.Em addition 831137db389SSteve Priceof existing users to a group without replacing the existing list of 8329fd0dafcSJoerg Wunschmembers. 833137db389SSteve PriceLogin names or user ids may be used, and duplicate users are 834137db389SSteve Pricesilently eliminated. 835bc991a6dSSean Farley.It Fl d Ar oldmembers 836bc991a6dSSean FarleySimilar to 837bc991a6dSSean Farley.Fl M , 838bc991a6dSSean Farleythis option allows the 839bc991a6dSSean Farley.Em deletion 840bc991a6dSSean Farleyof existing users from a group without replacing the existing list of 841bc991a6dSSean Farleymembers. 842bc991a6dSSean FarleyLogin names or user ids may be used, and duplicate users are 843bc991a6dSSean Farleysilently eliminated. 844d6f907dcSJoerg Wunsch.El 845d6f907dcSJoerg Wunsch.Pp 846d6f907dcSJoerg Wunsch.Ar groupadd 847d6f907dcSJoerg Wunschalso has a 84808657612SRuslan Ermilov.Fl o 849137db389SSteve Priceoption that allows allocation of an existing group id to a new group. 8501e4d5cf1SDevin TeskeThe default action is to reject an attempt to add a group, 8511e4d5cf1SDevin Teskeand this option overrides the check for duplicate group ids. 852d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id. 853d6f907dcSJoerg Wunsch.Pp 854d6f907dcSJoerg WunschThe 855d6f907dcSJoerg Wunsch.Ar groupmod 856137db389SSteve Pricecommand adds one additional option: 8579fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers" 8581e4d5cf1SDevin Teske.It Fl l Ar newname 859d6f907dcSJoerg WunschThis option allows changing of an existing group name to 8601e4d5cf1SDevin Teske.Ql \&newname . 8611e4d5cf1SDevin TeskeThe new name must not already exist, 8621e4d5cf1SDevin Teskeand any attempt to duplicate an existing group 863d6f907dcSJoerg Wunschname will be rejected. 864d6f907dcSJoerg Wunsch.El 865d6f907dcSJoerg Wunsch.Pp 866d6f907dcSJoerg WunschOptions for 867d6f907dcSJoerg Wunsch.Ar groupshow 868d6f907dcSJoerg Wunschare the same as for 869d6f907dcSJoerg Wunsch.Ar usershow , 870d6f907dcSJoerg Wunschwith the 87108657612SRuslan Ermilov.Fl g Ar gid 872d6f907dcSJoerg Wunschreplacing 87308657612SRuslan Ermilov.Fl u Ar uid 874d6f907dcSJoerg Wunschto specify the group id. 8754731d076SDima DorfmanThe 8764731d076SDima Dorfman.Fl 7 8774731d076SDima Dorfmanoption does not apply to the 8784731d076SDima Dorfman.Ar groupshow 8794731d076SDima Dorfmancommand. 880d6f907dcSJoerg Wunsch.Pp 8819fd0dafcSJoerg WunschThe command 8829fd0dafcSJoerg Wunsch.Ar groupnext 8839fd0dafcSJoerg Wunschreturns the next available group id on standard output. 884e468afb4SDima Dorfman.Sh USER LOCKING 885490d5836SPhilippe CharnierThe 886490d5836SPhilippe Charnier.Nm 887490d5836SPhilippe Charnierutility 888e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by 889e468afb4SDima Dorfmanprepending the string 890e468afb4SDima Dorfman.Ql *LOCKED* 891e468afb4SDima Dorfmanto the beginning of the password field in 892e468afb4SDima Dorfman.Pa master.passwd 893e468afb4SDima Dorfmanto prevent successful authentication. 894e468afb4SDima Dorfman.Pp 895e468afb4SDima DorfmanThe 896e468afb4SDima Dorfman.Ar lock 897e468afb4SDima Dorfmanand 898e468afb4SDima Dorfman.Ar unlock 899e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock, 90007bfccd7SRuslan Ermilovrespectively. 90107bfccd7SRuslan ErmilovThe 90208657612SRuslan Ermilov.Fl V , 90308657612SRuslan Ermilov.Fl C , 904e468afb4SDima Dorfmanand 90508657612SRuslan Ermilov.Fl q 906e468afb4SDima Dorfmanoptions as described above are accepted by these commands. 90759a3c79dSRuslan Ermilov.Sh NOTES 90859a3c79dSRuslan ErmilovFor a summary of options available with each command, you can use 90959a3c79dSRuslan Ermilov.Dl pw [command] help 91059a3c79dSRuslan ErmilovFor example, 91159a3c79dSRuslan Ermilov.Dl pw useradd help 91259a3c79dSRuslan Ermilovlists all available options for the useradd operation. 91359a3c79dSRuslan Ermilov.Pp 91459a3c79dSRuslan ErmilovThe 91559a3c79dSRuslan Ermilov.Nm 91659a3c79dSRuslan Ermilovutility allows 8-bit characters in the passwd GECOS field (user's full name, 91759a3c79dSRuslan Ermilovoffice, work and home phone number subfields), but disallows them in 91859a3c79dSRuslan Ermilovuser login and group names. 91959a3c79dSRuslan ErmilovUse 8-bit characters with caution, as connection to the Internet will 92059a3c79dSRuslan Ermilovrequire that your mail transport program supports 8BITMIME, and will 92159a3c79dSRuslan Ermilovconvert headers containing 8-bit characters to 7-bit quoted-printable 92259a3c79dSRuslan Ermilovformat. 92359a3c79dSRuslan Ermilov.Xr sendmail 8 92459a3c79dSRuslan Ermilovdoes support this. 92559a3c79dSRuslan ErmilovUse of 8-bit characters in the GECOS field should be used in 92659a3c79dSRuslan Ermilovconjunction with the user's default locale and character set 92759a3c79dSRuslan Ermilovand should not be implemented without their use. 92859a3c79dSRuslan ErmilovUsing 8-bit characters may also affect other 92959a3c79dSRuslan Ermilovprograms that transmit the contents of the GECOS field over the 93059a3c79dSRuslan ErmilovInternet, such as 93159a3c79dSRuslan Ermilov.Xr fingerd 8 , 93259a3c79dSRuslan Ermilovand a small number of TCP/IP clients, such as IRC, where full names 93359a3c79dSRuslan Ermilovspecified in the passwd file may be used by default. 93459a3c79dSRuslan Ermilov.Pp 93559a3c79dSRuslan ErmilovThe 93659a3c79dSRuslan Ermilov.Nm 93759a3c79dSRuslan Ermilovutility writes a log to the 93859a3c79dSRuslan Ermilov.Pa /var/log/userlog 93959a3c79dSRuslan Ermilovfile when actions such as user or group additions or deletions occur. 94059a3c79dSRuslan ErmilovThe location of this logfile can be changed in 94159a3c79dSRuslan Ermilov.Xr pw.conf 5 . 94259a3c79dSRuslan Ermilov.Sh FILES 94359a3c79dSRuslan Ermilov.Bl -tag -width /etc/master.passwd.new -compact 94459a3c79dSRuslan Ermilov.It Pa /etc/master.passwd 94559a3c79dSRuslan ErmilovThe user database 94659a3c79dSRuslan Ermilov.It Pa /etc/passwd 94759a3c79dSRuslan ErmilovA Version 7 format password file 94859a3c79dSRuslan Ermilov.It Pa /etc/login.conf 94959a3c79dSRuslan ErmilovThe user capabilities database 95059a3c79dSRuslan Ermilov.It Pa /etc/group 95159a3c79dSRuslan ErmilovThe group database 95259a3c79dSRuslan Ermilov.It Pa /etc/pw.conf 95359a3c79dSRuslan ErmilovPw default options file 95459a3c79dSRuslan Ermilov.It Pa /var/log/userlog 95559a3c79dSRuslan ErmilovUser/group modification logfile 95659a3c79dSRuslan Ermilov.El 9579b8a603eSWarren Block.Sh EXAMPLES 9589b8a603eSWarren BlockAdd new user Glurmo Smith (gsmith). 9599b8a603eSWarren BlockA gsmith login group is created if not already present. 9609b8a603eSWarren BlockThe login shell is set to 9619b8a603eSWarren Block.Xr csh 1 . 9629b8a603eSWarren BlockA new home directory at 9639b8a603eSWarren Block.Pa /home/gsmith 9649b8a603eSWarren Blockis created if it does not already exist. 9659b8a603eSWarren BlockFinally, a random password is generated and displayed: 9669b8a603eSWarren Block.Bd -literal -offset indent 9679b8a603eSWarren Blockpw useradd -n gsmith -c "Glurmo Smith" -s /bin/csh -m -w random 9689b8a603eSWarren Block.Ed 969*bb00e549SWarren Block.Pp 970*bb00e549SWarren BlockDelete the gsmith user and their home directory, including contents. 971*bb00e549SWarren Block.Bd -literal -offset indent 972*bb00e549SWarren Blockpw userdel -n gsmith -r 973*bb00e549SWarren Block.Ed 974a866e170SRuslan Ermilov.Sh EXIT STATUS 975490d5836SPhilippe CharnierThe 976490d5836SPhilippe Charnier.Nm 977490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise 978137db389SSteve Price.Nm 979137db389SSteve Pricereturns one of the 9809fd0dafcSJoerg Wunschfollowing exit codes defined by 9819fd0dafcSJoerg Wunsch.Xr sysexits 3 9829fd0dafcSJoerg Wunschas follows: 9839fd0dafcSJoerg Wunsch.Bl -tag -width xxxx 9849fd0dafcSJoerg Wunsch.It EX_USAGE 9859fd0dafcSJoerg Wunsch.Bl -bullet -compact 9869fd0dafcSJoerg Wunsch.It 9871dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option). 9889fd0dafcSJoerg Wunsch.El 9899fd0dafcSJoerg Wunsch.It EX_NOPERM 9909fd0dafcSJoerg Wunsch.Bl -bullet -compact 9919fd0dafcSJoerg Wunsch.It 9929fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root. 9939fd0dafcSJoerg Wunsch.El 9949fd0dafcSJoerg Wunsch.It EX_OSERR 9959fd0dafcSJoerg Wunsch.Bl -bullet -compact 9969fd0dafcSJoerg Wunsch.It 9979fd0dafcSJoerg WunschMemory allocation error. 9989fd0dafcSJoerg Wunsch.It 9999fd0dafcSJoerg WunschRead error from password file descriptor. 10009fd0dafcSJoerg Wunsch.El 10019fd0dafcSJoerg Wunsch.It EX_DATAERR 10029fd0dafcSJoerg Wunsch.Bl -bullet -compact 10039fd0dafcSJoerg Wunsch.It 10049fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or 1005137db389SSteve Pricevia the password file descriptor. 10069fd0dafcSJoerg Wunsch.It 10079fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid. 10089fd0dafcSJoerg Wunsch.El 10099fd0dafcSJoerg Wunsch.It EX_OSFILE 10109fd0dafcSJoerg Wunsch.Bl -bullet -compact 10119fd0dafcSJoerg Wunsch.It 10129fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist. 10139fd0dafcSJoerg Wunsch.It 10149fd0dafcSJoerg WunschBase home directory is invalid or does not exist. 10159fd0dafcSJoerg Wunsch.It 1016137db389SSteve PriceInvalid or non-existent shell specified. 10179fd0dafcSJoerg Wunsch.El 10189fd0dafcSJoerg Wunsch.It EX_NOUSER 10199fd0dafcSJoerg Wunsch.Bl -bullet -compact 10209fd0dafcSJoerg Wunsch.It 10219fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist. 10229fd0dafcSJoerg Wunsch.It 1023137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared. 10249fd0dafcSJoerg Wunsch.El 10259fd0dafcSJoerg Wunsch.It EX_SOFTWARE 10269fd0dafcSJoerg Wunsch.Bl -bullet -compact 10279fd0dafcSJoerg Wunsch.It 10289fd0dafcSJoerg WunschNo more group or user ids available within specified range. 10299fd0dafcSJoerg Wunsch.El 10309fd0dafcSJoerg Wunsch.It EX_IOERR 10319fd0dafcSJoerg Wunsch.Bl -bullet -compact 10329fd0dafcSJoerg Wunsch.It 10339fd0dafcSJoerg WunschUnable to rewrite configuration file. 10349fd0dafcSJoerg Wunsch.It 10359fd0dafcSJoerg WunschError updating group or user database files. 10369fd0dafcSJoerg Wunsch.It 10379fd0dafcSJoerg WunschUpdate error for passwd or group database files. 10389fd0dafcSJoerg Wunsch.El 10399fd0dafcSJoerg Wunsch.It EX_CONFIG 10409fd0dafcSJoerg Wunsch.Bl -bullet -compact 10419fd0dafcSJoerg Wunsch.It 10429fd0dafcSJoerg WunschNo base home directory configured. 10439fd0dafcSJoerg Wunsch.El 10449fd0dafcSJoerg Wunsch.El 1045d6f907dcSJoerg Wunsch.Sh SEE ALSO 1046d6f907dcSJoerg Wunsch.Xr chpass 1 , 1047053375e8SMike Pritchard.Xr passwd 1 , 1048eebbeceeSLukas Ertl.Xr umask 2 , 1049d6f907dcSJoerg Wunsch.Xr group 5 , 1050bfd34a4aSWolfram Schneider.Xr login.conf 5 , 1051053375e8SMike Pritchard.Xr passwd 5 , 1052053375e8SMike Pritchard.Xr pw.conf 5 , 1053d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 , 1054053375e8SMike Pritchard.Xr vipw 8 1055d6f907dcSJoerg Wunsch.Sh HISTORY 1056490d5836SPhilippe CharnierThe 1057490d5836SPhilippe Charnier.Nm 1058490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV 1059d6f907dcSJoerg Wunsch.Em shadow 10609fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to 1061053375e8SMike Pritchardthe 1062053375e8SMike Pritchard.Bx 4.4 10639fd0dafcSJoerg Wunschoperating system, and combines all of the major elements 10649fd0dafcSJoerg Wunschinto a single command. 1065