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*feb04c7bSMateusz Piotrowski.Dd April 3, 2022 28d6f907dcSJoerg Wunsch.Dt PW 8 29d6f907dcSJoerg Wunsch.Os 30d6f907dcSJoerg Wunsch.Sh NAME 31d6f907dcSJoerg Wunsch.Nm pw 329fd0dafcSJoerg Wunsch.Nd create, remove, modify & display system users and groups 33d6f907dcSJoerg Wunsch.Sh SYNOPSIS 34e97407b4SRuslan Ermilov.Nm 35a5b912ffSGlen Barber.Op Fl R Ar rootdir 365f12594aSDavid Nugent.Op Fl V Ar etcdir 375392b4fbSMateusz Piotrowski.Cm useradd 3839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name 3939245a7dSMateusz Piotrowski.Op Fl mNoPqY 40d6f907dcSJoerg Wunsch.Op Fl C Ar config 41d6f907dcSJoerg Wunsch.Op Fl c Ar comment 42*feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir 43*feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate 44d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist 4539245a7dSMateusz Piotrowski.Op Fl g Ar group 4639245a7dSMateusz Piotrowski.Op Fl H Ar fd 4739245a7dSMateusz Piotrowski.Op Fl h Ar fd 48*feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir 49d6f907dcSJoerg Wunsch.Op Fl L Ar class 5039245a7dSMateusz Piotrowski.Op Fl M Ar mode 51*feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate 5239245a7dSMateusz Piotrowski.Op Fl s Ar shell 5339245a7dSMateusz Piotrowski.Op Fl u Ar uid 54*feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod 55e97407b4SRuslan Ermilov.Nm 56a5b912ffSGlen Barber.Op Fl R Ar rootdir 575f12594aSDavid Nugent.Op Fl V Ar etcdir 585392b4fbSMateusz Piotrowski.Cm useradd 59f1d684faSDavid Nugent.Fl D 60d6f907dcSJoerg Wunsch.Op Fl q 61*feb04c7bSMateusz Piotrowski.Op Fl b Ar basehome 6239245a7dSMateusz Piotrowski.Op Fl C Ar config 63*feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdays 64d6f907dcSJoerg Wunsch.Op Fl G Ar grouplist 6539245a7dSMateusz Piotrowski.Op Fl g Ar group 66*feb04c7bSMateusz Piotrowski.Op Fl i Ar mingid , Ns Ar maxgid 67*feb04c7bSMateusz Piotrowski.Op Fl k Ar skeldir 68*feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdays 6939245a7dSMateusz Piotrowski.Op Fl s Ar shell 7085204142SLukas Ertl.Op Fl M Ar mode 71*feb04c7bSMateusz Piotrowski.Op Fl u Ar minuid , Ns Ar maxuid 72*feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod 73*feb04c7bSMateusz Piotrowski.Op Fl y Ar nispasswd 74e97407b4SRuslan Ermilov.Nm 75a5b912ffSGlen Barber.Op Fl R Ar rootdir 765f12594aSDavid Nugent.Op Fl V Ar etcdir 775392b4fbSMateusz Piotrowski.Cm userdel 7839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid 7939245a7dSMateusz Piotrowski.Op Fl rY 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 8539245a7dSMateusz Piotrowski.Op Fl mNPqY 86d6f907dcSJoerg Wunsch.Op Fl C Ar config 87d6f907dcSJoerg Wunsch.Op Fl c Ar comment 88*feb04c7bSMateusz Piotrowski.Op Fl d Ar homedir 89*feb04c7bSMateusz Piotrowski.Op Fl e Ar accexpdate 90*feb04c7bSMateusz 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 98*feb04c7bSMateusz Piotrowski.Op Fl p Ar passexpdate 9939245a7dSMateusz Piotrowski.Op Fl s Ar shell 100*feb04c7bSMateusz Piotrowski.Op Fl w Ar passmethod 101e97407b4SRuslan Ermilov.Nm 102a5b912ffSGlen Barber.Op Fl R Ar rootdir 1035f12594aSDavid Nugent.Op Fl V Ar etcdir 1045392b4fbSMateusz Piotrowski.Cm usershow 10539245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid 10639245a7dSMateusz Piotrowski.Op Fl 7aFP 107e97407b4SRuslan Ermilov.Nm 108a5b912ffSGlen Barber.Op Fl R Ar rootdir 1095f12594aSDavid Nugent.Op Fl V Ar etcdir 1105392b4fbSMateusz Piotrowski.Cm usernext 1113bfc59e8SBaptiste Daroussin.Op Fl q 11239245a7dSMateusz Piotrowski.Op Fl C Ar config 113e97407b4SRuslan Ermilov.Nm 114a5b912ffSGlen Barber.Op Fl R Ar rootdir 1155f12594aSDavid Nugent.Op Fl V Ar etcdir 1165392b4fbSMateusz Piotrowski.Cm groupadd 11739245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name 11839245a7dSMateusz Piotrowski.Op Fl oNPqY 119d6f907dcSJoerg Wunsch.Op Fl C Ar config 12039245a7dSMateusz Piotrowski.Op Fl g Ar gid 12139245a7dSMateusz Piotrowski.Op Fl H Ar fd 12239245a7dSMateusz Piotrowski.Op Fl h Ar fd 1239fd0dafcSJoerg Wunsch.Op Fl M Ar members 124e97407b4SRuslan Ermilov.Nm 125a5b912ffSGlen Barber.Op Fl R Ar rootdir 1265f12594aSDavid Nugent.Op Fl V Ar etcdir 1275392b4fbSMateusz Piotrowski.Cm groupdel 12839245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid 129f1d684faSDavid Nugent.Op Fl Y 130e97407b4SRuslan Ermilov.Nm 131a5b912ffSGlen Barber.Op Fl R Ar rootdir 1325f12594aSDavid Nugent.Op Fl V Ar etcdir 1335392b4fbSMateusz Piotrowski.Cm groupmod 1345392b4fbSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Ar gid Oo Fl g Ar newgid Oc | Fl g Ar gid 13539245a7dSMateusz Piotrowski.Op Fl NPqY 136d6f907dcSJoerg Wunsch.Op Fl C Ar config 13739245a7dSMateusz Piotrowski.Op Fl d Ar oldmembers 13839245a7dSMateusz Piotrowski.Op Fl H Ar fd 13939245a7dSMateusz Piotrowski.Op Fl h Ar fd 1401e4d5cf1SDevin Teske.Op Fl l Ar newname 1419fd0dafcSJoerg Wunsch.Op Fl M Ar members 1429fd0dafcSJoerg Wunsch.Op Fl m Ar newmembers 143e97407b4SRuslan Ermilov.Nm 144a5b912ffSGlen Barber.Op Fl R Ar rootdir 1455f12594aSDavid Nugent.Op Fl V Ar etcdir 1465392b4fbSMateusz Piotrowski.Cm groupshow 14739245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl g Oc Ar gid 14839245a7dSMateusz Piotrowski.Op Fl aFP 149e97407b4SRuslan Ermilov.Nm 150a5b912ffSGlen Barber.Op Fl R Ar rootdir 1515f12594aSDavid Nugent.Op Fl V Ar etcdir 1525392b4fbSMateusz Piotrowski.Cm groupnext 1539fd0dafcSJoerg Wunsch.Op Fl C Ar config 1543bfc59e8SBaptiste Daroussin.Op Fl q 155e468afb4SDima Dorfman.Nm 156a5b912ffSGlen Barber.Op Fl R Ar rootdir 157e468afb4SDima Dorfman.Op Fl V Ar etcdir 1585392b4fbSMateusz Piotrowski.Cm lock 15939245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid 160e468afb4SDima Dorfman.Op Fl q 16139245a7dSMateusz Piotrowski.Op Fl C Ar config 162e468afb4SDima Dorfman.Nm 163a5b912ffSGlen Barber.Op Fl R Ar rootdir 164e468afb4SDima Dorfman.Op Fl V Ar etcdir 1655392b4fbSMateusz Piotrowski.Cm unlock 16639245a7dSMateusz Piotrowski.Oo Fl n Oc Ar name Ns | Ns Oo Fl u Oc Ar uid 167e468afb4SDima Dorfman.Op Fl q 16839245a7dSMateusz Piotrowski.Op Fl C Ar config 169d6f907dcSJoerg Wunsch.Sh DESCRIPTION 170490d5836SPhilippe CharnierThe 171490d5836SPhilippe Charnier.Nm 172490d5836SPhilippe Charnierutility is a command-line based editor for the system 1731dcc6ec7SPhilippe Charnier.Ar user 174d6f907dcSJoerg Wunschand 1751dcc6ec7SPhilippe Charnier.Ar group 1763a7e7077SDaniel O'Callaghanfiles, allowing the superuser an easy to use and standardized way of adding, 177d6f907dcSJoerg Wunschmodifying and removing users and groups. 178d6f907dcSJoerg WunschNote that 1791dcc6ec7SPhilippe Charnier.Nm 180490d5836SPhilippe Charnieronly operates on the local user and group files. 181490d5836SPhilippe Charnier.Tn NIS 182490d5836SPhilippe Charnierusers and groups must be 183490d5836SPhilippe Charniermaintained on the 184490d5836SPhilippe Charnier.Tn NIS 185490d5836SPhilippe Charnierserver. 186490d5836SPhilippe CharnierThe 187490d5836SPhilippe Charnier.Nm 188490d5836SPhilippe Charnierutility handles updating the 18961e11ed9SMateusz Piotrowski.Xr passwd 5 , 19061e11ed9SMateusz Piotrowski.Xr master.passwd 5 , 19161e11ed9SMateusz Piotrowski.Xr group 5 192053375e8SMike Pritchardand the secure and insecure 193d6f907dcSJoerg Wunschpassword database files, and must be run as root. 194d6f907dcSJoerg Wunsch.Pp 195137db389SSteve PriceThe first one or two keywords provided to 196137db389SSteve Price.Nm 197137db389SSteve Priceon the command line provide the context for the remainder of the arguments. 198137db389SSteve PriceThe keywords 19961e11ed9SMateusz Piotrowski.Cm user 200d6f907dcSJoerg Wunschand 20161e11ed9SMateusz Piotrowski.Cm group 202137db389SSteve Pricemay be combined with 20361e11ed9SMateusz Piotrowski.Cm add , 20461e11ed9SMateusz Piotrowski.Cm del , 20561e11ed9SMateusz Piotrowski.Cm mod , 20661e11ed9SMateusz Piotrowski.Cm show , 2079fd0dafcSJoerg Wunschor 20861e11ed9SMateusz Piotrowski.Cm next 2094e86fcacSSheldon Hearnin any order. 2104e86fcacSSheldon Hearn(For example, 21161e11ed9SMateusz Piotrowski.Cm showuser , 21261e11ed9SMateusz Piotrowski.Cm usershow , 21361e11ed9SMateusz Piotrowski.Cm show user , 214610a5778SRuslan Ermilovand 21561e11ed9SMateusz Piotrowski.Cm user show 216137db389SSteve Priceall mean the same thing.) 217137db389SSteve PriceThis flexibility is useful for interactive scripts calling 2181dcc6ec7SPhilippe Charnier.Nm 219137db389SSteve Pricefor user and group database manipulation. 2201e4d5cf1SDevin TeskeFollowing these keywords, 2211e4d5cf1SDevin Teskethe user or group name or numeric id may be optionally specified as an 2221e4d5cf1SDevin Teskealternative to using the 223d6f907dcSJoerg Wunsch.Fl n Ar name , 224d6f907dcSJoerg Wunsch.Fl u Ar uid , 225d6f907dcSJoerg Wunsch.Fl g Ar gid 2269fd0dafcSJoerg Wunschoptions. 227d6f907dcSJoerg Wunsch.Pp 228d5a3b1edSDima DorfmanThe following flags are common to most or all modes of operation: 2299fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist" 230a5b912ffSGlen Barber.It Fl R Ar rootdir 231a5b912ffSGlen BarberSpecifies an alternate root directory within which 232a5b912ffSGlen Barber.Nm 233a5b912ffSGlen Barberwill operate. 234a5b912ffSGlen BarberAny paths specified will be relative to 235a5b912ffSGlen Barber.Va rootdir . 2365f12594aSDavid Nugent.It Fl V Ar etcdir 2371e4d5cf1SDevin TeskeSet an alternate location for the password, group, and configuration files. 2381e4d5cf1SDevin TeskeCan be used to maintain a user/group database in an alternate location. 2395f12594aSDavid NugentIf this switch is specified, the system 2405f12594aSDavid Nugent.Pa /etc/pw.conf 2411e4d5cf1SDevin Teskewill not be sourced for default configuration data, 24261e11ed9SMateusz Piotrowskibut the file 24361e11ed9SMateusz Piotrowski.Pa pw.conf 24461e11ed9SMateusz Piotrowskiin the specified directory will be used instead 2451e4d5cf1SDevin Teske.Pq or none, if it does not exist . 2465f12594aSDavid NugentThe 2475f12594aSDavid Nugent.Fl C 2485f12594aSDavid Nugentflag may be used to override this behaviour. 2495f12594aSDavid NugentAs an exception to the general rule where options must follow the operation 2505f12594aSDavid Nugenttype, the 2515f12594aSDavid Nugent.Fl V 2524369c82dSBaptiste Daroussinflag must be used on the command line before the operation keyword. 253d6f907dcSJoerg Wunsch.It Fl C Ar config 254d6f907dcSJoerg WunschBy default, 2551dcc6ec7SPhilippe Charnier.Nm 256d6f907dcSJoerg Wunschreads the file 257d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 258137db389SSteve Priceto obtain policy information on how new user accounts and groups are to be created. 259137db389SSteve PriceThe 2609fd0dafcSJoerg Wunsch.Fl C 2619fd0dafcSJoerg Wunschoption specifies a different configuration file. 262137db389SSteve PriceWhile most of the contents of the configuration file may be overridden via 263137db389SSteve Pricecommand-line options, it may be more convenient to keep standard information in a 264137db389SSteve Priceconfiguration file. 265d6f907dcSJoerg Wunsch.It Fl q 266d6f907dcSJoerg WunschUse of this option causes 2671dcc6ec7SPhilippe Charnier.Nm 2681e4d5cf1SDevin Tesketo suppress error messages, 2691e4d5cf1SDevin Teskewhich may be useful in interactive environments where it 270d6f907dcSJoerg Wunschis preferable to interpret status codes returned by 2711dcc6ec7SPhilippe Charnier.Nm 272d6f907dcSJoerg Wunschrather than messing up a carefully formatted display. 2739fd0dafcSJoerg Wunsch.It Fl N 274137db389SSteve PriceThis option is available in 27561e11ed9SMateusz Piotrowski.Cm add 276137db389SSteve Priceand 27761e11ed9SMateusz Piotrowski.Cm modify 278137db389SSteve Priceoperations, and tells 2791dcc6ec7SPhilippe Charnier.Nm 280137db389SSteve Priceto output the result of the operation without updating the user or group 281137db389SSteve Pricedatabases. 2829fd0dafcSJoerg WunschYou may use the 2839fd0dafcSJoerg Wunsch.Fl P 2849fd0dafcSJoerg Wunschoption to switch between standard passwd and readable formats. 285f1d684faSDavid Nugent.It Fl Y 286f1d684faSDavid NugentUsing this option with any of the update modes causes 2871dcc6ec7SPhilippe Charnier.Nm 288f1d684faSDavid Nugentto run 289f1d684faSDavid Nugent.Xr make 1 290f1d684faSDavid Nugentafter changing to the directory 291f1d684faSDavid Nugent.Pa /var/yp . 292490d5836SPhilippe CharnierThis is intended to allow automatic updating of 293490d5836SPhilippe Charnier.Tn NIS 294490d5836SPhilippe Charnierdatabase files. 295490d5836SPhilippe CharnierIf separate passwd and group files are being used by 296490d5836SPhilippe Charnier.Tn NIS , 297490d5836SPhilippe Charnierthen use the 298*feb04c7bSMateusz Piotrowski.Fl y Ar nispasswd 299490d5836SPhilippe Charnieroption to specify the location of the 300490d5836SPhilippe Charnier.Tn NIS 301490d5836SPhilippe Charnierpasswd database so that 302137db389SSteve Price.Nm 303137db389SSteve Pricewill concurrently update it with the system password 304f1d684faSDavid Nugentdatabases. 305d6f907dcSJoerg Wunsch.El 306d6f907dcSJoerg Wunsch.Sh USER OPTIONS 307d6f907dcSJoerg WunschThe following options apply to the 30877fd0356SMateusz Piotrowski.Cm useradd 309d6f907dcSJoerg Wunschand 31077fd0356SMateusz Piotrowski.Cm usermod 311d6f907dcSJoerg Wunschcommands: 3129fd0dafcSJoerg Wunsch.Bl -tag -width "-G grouplist" 3131e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name 3141e4d5cf1SDevin TeskeRequired unless 3151e4d5cf1SDevin Teske.Fl u Ar uid 3161e4d5cf1SDevin Teskeis given. 3171dcc6ec7SPhilippe CharnierSpecify the user/account name. 3181e4d5cf1SDevin TeskeIn the case of 31977fd0356SMateusz Piotrowski.Cm usermod 32077fd0356SMateusz Piotrowskican be a 32177fd0356SMateusz Piotrowski.Ar uid . 322d6f907dcSJoerg Wunsch.It Fl u Ar uid 3231e4d5cf1SDevin TeskeRequired if 3241e4d5cf1SDevin Teske.Ar name 3251e4d5cf1SDevin Teskeis not given. 3261dcc6ec7SPhilippe CharnierSpecify the user/account numeric id. 3271e4d5cf1SDevin TeskeIn the case of 32877fd0356SMateusz Piotrowski.Cm usermod 3291e4d5cf1SDevin Teskeif paired with 3301e4d5cf1SDevin Teske.Ar name , 3311e4d5cf1SDevin Teskechanges the numeric id of the named user/account. 332d6f907dcSJoerg Wunsch.Pp 3331e4d5cf1SDevin TeskeUsually, only one of these options is required, 3341e4d5cf1SDevin Teskeas the account name will imply the uid, or vice versa. 3351e4d5cf1SDevin TeskeHowever, there are times when both are needed. 336d6f907dcSJoerg WunschFor example, when changing the uid of an existing user with 33777fd0356SMateusz Piotrowski.Cm usermod , 3381e4d5cf1SDevin Teskeor overriding the default uid when creating a new account with 33977fd0356SMateusz Piotrowski.Cm useradd . 3401e4d5cf1SDevin TeskeTo automatically allocate the uid to a new user with 34177fd0356SMateusz Piotrowski.Cm useradd , 3421e4d5cf1SDevin Teskethen do 343d6f907dcSJoerg Wunsch.Em not 344d6f907dcSJoerg Wunschuse the 34508657612SRuslan Ermilov.Fl u 3469fd0dafcSJoerg Wunschoption. 3471e4d5cf1SDevin TeskeEither the account or userid can also be provided immediately after the 34877fd0356SMateusz Piotrowski.Cm useradd , 34977fd0356SMateusz Piotrowski.Cm userdel , 35077fd0356SMateusz Piotrowski.Cm usermod , 351137db389SSteve Priceor 35277fd0356SMateusz Piotrowski.Cm usershow 353137db389SSteve Pricekeywords on the command line without using the 35408657612SRuslan Ermilov.Fl n 355137db389SSteve Priceor 35608657612SRuslan Ermilov.Fl u 357137db389SSteve Priceoptions. 358d6f907dcSJoerg Wunsch.El 359d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist" 360d6f907dcSJoerg Wunsch.It Fl c Ar comment 3611e4d5cf1SDevin TeskeThis field sets the contents of the passwd GECOS field, 3621e4d5cf1SDevin Teskewhich normally contains up to four comma-separated fields containing the 3631e4d5cf1SDevin Teskeuser's full name, office or location, 364137db389SSteve Priceand work and home phone numbers. 365d6f907dcSJoerg WunschThese sub-fields are used by convention only, however, and are optional. 3661e4d5cf1SDevin TeskeIf this field is to contain spaces, 3671e4d5cf1SDevin Teskethe comment must be enclosed in double quotes 368d6f907dcSJoerg Wunsch.Ql \&" . 3691e4d5cf1SDevin TeskeAvoid using commas in this field as these are used as sub-field separators, 3701e4d5cf1SDevin Teskeand the colon 371d6f907dcSJoerg Wunsch.Ql \&: 372137db389SSteve Pricecharacter also cannot be used as this is the field separator for the passwd 373137db389SSteve Pricefile itself. 374*feb04c7bSMateusz Piotrowski.It Fl d Ar homedir 375d6f907dcSJoerg WunschThis option sets the account's home directory. 3761e4d5cf1SDevin TeskeNormally, 3771e4d5cf1SDevin Teskethis is only used if the home directory is to be different from the 378137db389SSteve Pricedefault determined from 379137db389SSteve Price.Pa /etc/pw.conf 3801dcc6ec7SPhilippe Charnier- normally 3811dcc6ec7SPhilippe Charnier.Pa /home 382137db389SSteve Pricewith the account name as a subdirectory. 383*feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdate 3841dcc6ec7SPhilippe CharnierSet the account's expiration date. 385d6f907dcSJoerg WunschFormat of the date is either a UNIX time in decimal, or a date in 386137db389SSteve Price.Ql dd-mmm-yy[yy] 3871e4d5cf1SDevin Teskeformat, where dd is the day, 3881e4d5cf1SDevin Teskemmm is the month, either in numeric or alphabetic format 3891dcc6ec7SPhilippe Charnier('Jan', 'Feb', etc) and year is either a two or four digit year. 390d6f907dcSJoerg WunschThis option also accepts a relative date in the form 391d6f907dcSJoerg Wunsch.Ql \&+n[mhdwoy] 392d6f907dcSJoerg Wunschwhere 393d6f907dcSJoerg Wunsch.Ql \&n 3941e4d5cf1SDevin Teskeis a decimal, 3951e4d5cf1SDevin Teskeoctal (leading 0) or hexadecimal (leading 0x) digit followed by the 396053375e8SMike Pritchardnumber of Minutes, Hours, Days, Weeks, Months or Years from the current date at 397137db389SSteve Pricewhich the expiration date is to be set. 398*feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdate 3991dcc6ec7SPhilippe CharnierSet the account's password expiration date. 400137db389SSteve PriceThis field is similar to the account expiration date option, except that it 401d6f907dcSJoerg Wunschapplies to forced password changes. 402137db389SSteve PriceThis is set in the same manner as the 40308657612SRuslan Ermilov.Fl e 404137db389SSteve Priceoption. 405d6f907dcSJoerg Wunsch.It Fl g Ar group 4061dcc6ec7SPhilippe CharnierSet the account's primary group to the given group. 407d6f907dcSJoerg Wunsch.Ar group 408137db389SSteve Pricemay be defined by either its name or group number. 409d6f907dcSJoerg Wunsch.It Fl G Ar grouplist 410579a636fSWarren BlockSet secondary group memberships for an account. 411d6f907dcSJoerg Wunsch.Ar grouplist 412579a636fSWarren Blockis a comma, space, or tab-separated list of group names or group numbers. 413579a636fSWarren BlockThe user is added to the groups specified in 414579a636fSWarren Block.Ar grouplist , 415579a636fSWarren Blockand removed from all groups not specified. 416579a636fSWarren BlockThe current login session is not affected by group membership changes, 417579a636fSWarren Blockwhich only take effect when the user reconnects. 418579a636fSWarren BlockNote: do not add a user to their primary group with 419d6f907dcSJoerg Wunsch.Ar grouplist . 4209fd0dafcSJoerg Wunsch.It Fl L Ar class 4219fd0dafcSJoerg WunschThis option sets the login class for the user being created. 4229fd0dafcSJoerg WunschSee 4239fd0dafcSJoerg Wunsch.Xr login.conf 5 42416b4ad52SGiorgos Keramidasand 42516b4ad52SGiorgos Keramidas.Xr passwd 5 426137db389SSteve Pricefor more information on user login classes. 427d6f907dcSJoerg Wunsch.It Fl m 428d6f907dcSJoerg WunschThis option instructs 4291dcc6ec7SPhilippe Charnier.Nm 430d6f907dcSJoerg Wunschto attempt to create the user's home directory. 431d6f907dcSJoerg WunschWhile primarily useful when adding a new account with 43277fd0356SMateusz Piotrowski.Cm useradd , 4331e4d5cf1SDevin Teskethis may also be of use when moving an existing user's home directory elsewhere 4341e4d5cf1SDevin Teskeon the file system. 435d6f907dcSJoerg WunschThe new home directory is populated with the contents of the 436d6f907dcSJoerg Wunsch.Ar skeleton 437d6f907dcSJoerg Wunschdirectory, which typically contains a set of shell configuration files that the 438053375e8SMike Pritcharduser may personalize to taste. 43931e224ddSTom RhodesFiles in this directory are usually named 440fd59f59aSTom Rhodes.Pa dot . Ns Aq Ar config 44131e224ddSTom Rhodeswhere the 442fd59f59aSTom Rhodes.Pa dot 44331e224ddSTom Rhodesprefix will be stripped. 444d6f907dcSJoerg WunschWhen 44508657612SRuslan Ermilov.Fl m 446d6f907dcSJoerg Wunschis used on an account with 44777fd0356SMateusz Piotrowski.Cm usermod , 448137db389SSteve Priceexisting configuration files in the user's home directory are 449d6f907dcSJoerg Wunsch.Em not 450137db389SSteve Priceoverwritten from the skeleton files. 451d6f907dcSJoerg Wunsch.Pp 4521e4d5cf1SDevin TeskeWhen a user's home directory is created, 4531e4d5cf1SDevin Teskeit will by default be a subdirectory of the 454d6f907dcSJoerg Wunsch.Ar basehome 455137db389SSteve Pricedirectory as specified by the 45608657612SRuslan Ermilov.Fl b 45777fd0356SMateusz Piotrowskioption, bearing the name of the new account. 458137db389SSteve PriceThis can be overridden by the 45908657612SRuslan Ermilov.Fl d 460d6f907dcSJoerg Wunschoption on the command line, if desired. 461eebbeceeSLukas Ertl.It Fl M Ar mode 462eebbeceeSLukas ErtlCreate the user's home directory with the specified 46385204142SLukas Ertl.Ar mode , 46485204142SLukas Ertlmodified by the current 46585204142SLukas Ertl.Xr umask 2 . 466eebbeceeSLukas ErtlIf omitted, it is derived from the parent process' 467eebbeceeSLukas Ertl.Xr umask 2 . 468eebbeceeSLukas ErtlThis option is only useful in combination with the 469eebbeceeSLukas Ertl.Fl m 470eebbeceeSLukas Ertlflag. 471*feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir 4721dcc6ec7SPhilippe CharnierSet the 473d6f907dcSJoerg Wunsch.Ar skeleton 474137db389SSteve Pricedirectory, from which basic startup and configuration files are copied when 475d6f907dcSJoerg Wunschthe user's home directory is created. 476137db389SSteve PriceThis option only has meaning when used with the 47708657612SRuslan Ermilov.Fl d 478137db389SSteve Priceor 47908657612SRuslan Ermilov.Fl m 480137db389SSteve Priceflags. 481d6f907dcSJoerg Wunsch.It Fl s Ar shell 4821dcc6ec7SPhilippe CharnierSet or changes the user's login shell to 483d6f907dcSJoerg Wunsch.Ar shell . 484d6f907dcSJoerg WunschIf the path to the shell program is omitted, 4851dcc6ec7SPhilippe Charnier.Nm 486d6f907dcSJoerg Wunschsearches the 487d6f907dcSJoerg Wunsch.Ar shellpath 488d6f907dcSJoerg Wunschspecified in 489d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 490d6f907dcSJoerg Wunschand fills it in as appropriate. 491d6f907dcSJoerg WunschNote that unless you have a specific reason to do so, you should avoid 492d6f907dcSJoerg Wunschspecifying the path - this will allow 4931dcc6ec7SPhilippe Charnier.Nm 494d6f907dcSJoerg Wunschto validate that the program exists and is executable. 495d6f907dcSJoerg WunschSpecifying a full path (or supplying a blank "" shell) avoids this check 496d6f907dcSJoerg Wunschand allows for such entries as 4971dcc6ec7SPhilippe Charnier.Pa /nonexistent 498d6f907dcSJoerg Wunschthat should be set for accounts not intended for interactive login. 499d6f907dcSJoerg Wunsch.It Fl h Ar fd 500d6f907dcSJoerg WunschThis option provides a special interface by which interactive scripts can 501d6f907dcSJoerg Wunschset an account password using 502e97407b4SRuslan Ermilov.Nm . 503137db389SSteve PriceBecause the command line and environment are fundamentally insecure mechanisms 504d6f907dcSJoerg Wunschby which programs can accept information, 5051dcc6ec7SPhilippe Charnier.Nm 506d6f907dcSJoerg Wunschwill only allow setting of account and group passwords via a file descriptor 507d6f907dcSJoerg Wunsch(usually a pipe between an interactive script and the program). 508d6f907dcSJoerg Wunsch.Ar sh , 509d6f907dcSJoerg Wunsch.Ar bash , 510d6f907dcSJoerg Wunsch.Ar ksh 511d6f907dcSJoerg Wunschand 512d6f907dcSJoerg Wunsch.Ar perl 513137db389SSteve Priceall possess mechanisms by which this can be done. 514d6f907dcSJoerg WunschAlternatively, 515325970a9SPhilippe Charnier.Nm 516d6f907dcSJoerg Wunschwill prompt for the user's password if 51708657612SRuslan Ermilov.Fl h Ar 0 518d6f907dcSJoerg Wunschis given, nominating 519d6f907dcSJoerg Wunsch.Em stdin 520d6f907dcSJoerg Wunschas the file descriptor on which to read the password. 521137db389SSteve PriceNote that this password will be read only once and is intended 522137db389SSteve Pricefor use by a script rather than for interactive use. 523d6f907dcSJoerg WunschIf you wish to have new password confirmation along the lines of 524d6f907dcSJoerg Wunsch.Xr passwd 1 , 525137db389SSteve Pricethis must be implemented as part of an interactive script that calls 526e97407b4SRuslan Ermilov.Nm . 527d6f907dcSJoerg Wunsch.Pp 528d6f907dcSJoerg WunschIf a value of 529d6f907dcSJoerg Wunsch.Ql \&- 530d6f907dcSJoerg Wunschis given as the argument 531d6f907dcSJoerg Wunsch.Ar fd , 532d6f907dcSJoerg Wunschthen the password will be set to 533d6f907dcSJoerg Wunsch.Ql \&* , 534137db389SSteve Pricerendering the account inaccessible via password-based login. 53587d6b5caSIan Dowse.It Fl H Ar fd 53687d6b5caSIan DowseRead an encrypted password string from the specified file descriptor. 53787d6b5caSIan DowseThis is like 53887d6b5caSIan Dowse.Fl h , 53987d6b5caSIan Dowsebut the password should be supplied already encrypted in a form 54087d6b5caSIan Dowsesuitable for writing directly to the password database. 541d6f907dcSJoerg Wunsch.El 542d6f907dcSJoerg Wunsch.Pp 543d6f907dcSJoerg WunschIt is possible to use 54477fd0356SMateusz Piotrowski.Cm useradd 545d6f907dcSJoerg Wunschto create a new account that duplicates an existing user id. 546d6f907dcSJoerg WunschWhile this is normally considered an error and will be rejected, the 54708657612SRuslan Ermilov.Fl o 5489fd0dafcSJoerg Wunschoption overrides the check for duplicates and allows the duplication of 5499fd0dafcSJoerg Wunschthe user id. 5509fd0dafcSJoerg WunschThis may be useful if you allow the same user to login under 5519fd0dafcSJoerg Wunschdifferent contexts (different group allocations, different home 5529fd0dafcSJoerg Wunschdirectory, different shell) while providing basically the same 5539fd0dafcSJoerg Wunschpermissions for access to the user's files in each account. 554d6f907dcSJoerg Wunsch.Pp 555d6f907dcSJoerg WunschThe 55677fd0356SMateusz Piotrowski.Cm useradd 557d6f907dcSJoerg Wunschcommand also has the ability to set new user and group defaults by using the 55808657612SRuslan Ermilov.Fl D 5599fd0dafcSJoerg Wunschoption. 560d6f907dcSJoerg WunschInstead of adding a new user, 5611dcc6ec7SPhilippe Charnier.Nm 562d6f907dcSJoerg Wunschwrites a new set of defaults to its configuration file, 563d6f907dcSJoerg Wunsch.Pa /etc/pw.conf . 564d6f907dcSJoerg WunschWhen using the 56508657612SRuslan Ermilov.Fl D 5669fd0dafcSJoerg Wunschoption, you must not use either 56708657612SRuslan Ermilov.Fl n Ar name 568d6f907dcSJoerg Wunschor 56908657612SRuslan Ermilov.Fl u Ar uid 570d6f907dcSJoerg Wunschor an error will result. 571d6f907dcSJoerg WunschUse of 57208657612SRuslan Ermilov.Fl D 5739fd0dafcSJoerg Wunschchanges the meaning of several command line switches in the 574d6f907dcSJoerg Wunsch.Ar useradd 575d6f907dcSJoerg Wunschcommand. 576d6f907dcSJoerg WunschThese are: 577d6f907dcSJoerg Wunsch.Bl -tag -width "-G grouplist" 578d6f907dcSJoerg Wunsch.It Fl D 579d6f907dcSJoerg WunschSet default values in 580d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 581d6f907dcSJoerg Wunschconfiguration file, or a different named configuration file if the 58208657612SRuslan Ermilov.Fl C Ar config 5839fd0dafcSJoerg Wunschoption is used. 584*feb04c7bSMateusz Piotrowski.It Fl b Ar basehome 5851dcc6ec7SPhilippe CharnierSet the root directory in which user home directories are created. 586d6f907dcSJoerg WunschThe default value for this is 5871dcc6ec7SPhilippe Charnier.Pa /home , 588d6f907dcSJoerg Wunschbut it may be set elsewhere as desired. 589*feb04c7bSMateusz Piotrowski.It Fl e Ar accexpdays 5901dcc6ec7SPhilippe CharnierSet the default account expiration period in days. 5911e4d5cf1SDevin TeskeWhen 5921e4d5cf1SDevin Teske.Fl D 5931e4d5cf1SDevin Teskeis used, the 594*feb04c7bSMateusz Piotrowski.Ar accexpdays 5951e4d5cf1SDevin Teskeargument is interpreted differently. 5961e4d5cf1SDevin TeskeIt must be numeric and represents the number of days after creation 5971e4d5cf1SDevin Teskethat the account expires. 598d6f907dcSJoerg WunschA value of 0 suppresses automatic calculation of the expiry date. 599*feb04c7bSMateusz Piotrowski.It Fl p Ar passexpdays 6001dcc6ec7SPhilippe CharnierSet the default password expiration period in days. 601d30f122fSEugene GrosbeinWhen 602d30f122fSEugene Grosbein.Fl D 603d30f122fSEugene Grosbeinis used, the 604*feb04c7bSMateusz Piotrowski.Ar passexpdays 605d30f122fSEugene Grosbeinargument is interpreted differently. 606d30f122fSEugene GrosbeinIt must be numeric and represents the number of days after creation 607d30f122fSEugene Grosbeinthat the account expires. 608d30f122fSEugene GrosbeinA value of 0 suppresses automatic calculation of the expiry date. 609d6f907dcSJoerg Wunsch.It Fl g Ar group 6101dcc6ec7SPhilippe CharnierSet the default group for new users. 611d6f907dcSJoerg WunschIf a blank group is specified using 61208657612SRuslan Ermilov.Fl g Ar \&"" , 613137db389SSteve Pricethen new users will be allocated their own private primary group 614137db389SSteve Pricewith the same name as their login name. 615d6f907dcSJoerg WunschIf a group is supplied, either its name or uid may be given as an argument. 616d6f907dcSJoerg Wunsch.It Fl G Ar grouplist 617137db389SSteve PriceSet the default groups in which new users are granted membership. 6181e4d5cf1SDevin TeskeThis is a separate set of groups from the primary group. 6191e4d5cf1SDevin TeskeAvoid nominating the same group as both primary and extra groups. 620d6f907dcSJoerg WunschIn other words, these extra groups determine membership in groups 621d6f907dcSJoerg Wunsch.Em other than 622d6f907dcSJoerg Wunschthe primary group. 623d6f907dcSJoerg Wunsch.Ar grouplist 624137db389SSteve Priceis a comma-separated list of group names or ids, and are always 625d6f907dcSJoerg Wunschstored in 626d6f907dcSJoerg Wunsch.Pa /etc/pw.conf 627d6f907dcSJoerg Wunschby their symbolic names. 6289fd0dafcSJoerg Wunsch.It Fl L Ar class 6299fd0dafcSJoerg WunschThis option sets the default login class for new users. 630*feb04c7bSMateusz Piotrowski.It Fl k Ar skeldir 6311dcc6ec7SPhilippe CharnierSet the default 632d6f907dcSJoerg Wunsch.Em skeleton 6331e4d5cf1SDevin Teskedirectory, 6341e4d5cf1SDevin Teskefrom which prototype shell and other initialization files are copied when 6351dcc6ec7SPhilippe Charnier.Nm 636d6f907dcSJoerg Wunschcreates a user's home directory. 63731e224ddSTom RhodesSee description of 63831e224ddSTom Rhodes.Fl k 63931e224ddSTom Rhodesfor naming conventions of these files. 640610a5778SRuslan Ermilov.It Xo 641*feb04c7bSMateusz Piotrowski.Fl u Ar minuid Ns Cm \&, Ns Ar maxuid , 642*feb04c7bSMateusz Piotrowski.Fl i Ar mingid Ns Cm \&, Ns Ar maxgid 643610a5778SRuslan Ermilov.Xc 6441e4d5cf1SDevin TeskeSet the minimum and maximum user and group ids allocated for new 6451e4d5cf1SDevin Teskeaccounts and groups created by 646e97407b4SRuslan Ermilov.Nm . 647d6f907dcSJoerg WunschThe default values for each is 1000 minimum and 32000 maximum. 648*feb04c7bSMateusz Piotrowski.Ar minuid 649d6f907dcSJoerg Wunschand 650*feb04c7bSMateusz Piotrowski.Ar maxuid 6511e4d5cf1SDevin Teskeare both numbers, where max must be greater than min, 652*feb04c7bSMateusz Piotrowskiand both must be between 0 and 32767 653*feb04c7bSMateusz Piotrowski.Po the same applies to 654*feb04c7bSMateusz Piotrowski.Ar mingid 655*feb04c7bSMateusz Piotrowskiand 656*feb04c7bSMateusz Piotrowski.Ar maxgid 657*feb04c7bSMateusz Piotrowski.Pc . 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 . 662*feb04c7bSMateusz Piotrowski.It Fl w Ar passmethod 663d6f907dcSJoerg WunschThe 66408657612SRuslan Ermilov.Fl w 6651e4d5cf1SDevin Teskeoption selects the default method used to set passwords for newly created user 6661e4d5cf1SDevin Teskeaccounts. 667*feb04c7bSMateusz Piotrowski.Ar passmethod 668d6f907dcSJoerg Wunschis one of: 669d6f907dcSJoerg Wunsch.Pp 670d6f907dcSJoerg Wunsch.Bl -tag -width random -offset indent -compact 67177fd0356SMateusz Piotrowski.It Cm no 6721dcc6ec7SPhilippe Charnierdisable login on newly created accounts 67377fd0356SMateusz Piotrowski.It Cm yes 6741dcc6ec7SPhilippe Charnierforce the password to be the account name 67577fd0356SMateusz Piotrowski.It Cm none 6761dcc6ec7SPhilippe Charnierforce a blank password 67777fd0356SMateusz Piotrowski.It Cm random 6781dcc6ec7SPhilippe Charniergenerate a random password 679d6f907dcSJoerg Wunsch.El 680d6f907dcSJoerg Wunsch.Pp 681d6f907dcSJoerg WunschThe 68277fd0356SMateusz Piotrowski.Cm random 683d6f907dcSJoerg Wunschor 68477fd0356SMateusz Piotrowski.Cm 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 69377fd0356SMateusz Piotrowski.Cm 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 71177fd0356SMateusz Piotrowski.Cm 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 72977fd0356SMateusz Piotrowskianother account on the system, and the 73077fd0356SMateusz Piotrowski.Dq home 73177fd0356SMateusz Piotrowskidirectory in the password file is 732d6f907dcSJoerg Wunscha valid path that commences with the character 733d6f907dcSJoerg Wunsch.Ql \&/ . 734d6f907dcSJoerg WunschSecondly, it will only remove files and directories that are actually owned by 735d6f907dcSJoerg Wunschthe user, or symbolic links owned by anyone under the user's home directory. 736d6f907dcSJoerg WunschFinally, after deleting all contents owned by the user only empty directories 737d6f907dcSJoerg Wunschwill be removed. 738053375e8SMike PritchardIf any additional cleanup work is required, this is left to the administrator. 739d6f907dcSJoerg Wunsch.El 740d6f907dcSJoerg Wunsch.Pp 74177fd0356SMateusz PiotrowskiMail spool files and 74277fd0356SMateusz Piotrowski.Xr crontab 5 74377fd0356SMateusz Piotrowskifiles are always removed when an account is deleted as 7441e4d5cf1SDevin Teskethese are unconditionally attached to the user name. 745d6f907dcSJoerg WunschJobs queued for processing by 74677fd0356SMateusz Piotrowski.Xr at 1 7471e4d5cf1SDevin Teskeare also removed if the user's uid is unique and not also used by another 7481e4d5cf1SDevin Teskeaccount on the system. 749d6f907dcSJoerg Wunsch.Pp 750d6f907dcSJoerg WunschThe 75177fd0356SMateusz Piotrowski.Cm usermod 75219e1bf29SEitan Adlercommand adds one additional option: 75319e1bf29SEitan Adler.Bl -tag -width "-G grouplist" 7541e4d5cf1SDevin Teske.It Fl l Ar newname 75519e1bf29SEitan AdlerThis option allows changing of an existing account name to 75677fd0356SMateusz Piotrowski.Ar newname . 75719e1bf29SEitan AdlerThe new name must not already exist, and any attempt to duplicate an 75819e1bf29SEitan Adlerexisting account name will be rejected. 75919e1bf29SEitan Adler.El 76019e1bf29SEitan Adler.Pp 76119e1bf29SEitan AdlerThe 76277fd0356SMateusz Piotrowski.Cm usershow 763d6f907dcSJoerg Wunschcommand allows viewing of an account in one of two formats. 764d6f907dcSJoerg WunschBy default, the format is identical to the format used in 765d6f907dcSJoerg Wunsch.Pa /etc/master.passwd 766d6f907dcSJoerg Wunschwith the password field replaced with a 767d6f907dcSJoerg Wunsch.Ql \&* . 768d6f907dcSJoerg WunschIf the 76908657612SRuslan Ermilov.Fl P 7709fd0dafcSJoerg Wunschoption is used, then 7711dcc6ec7SPhilippe Charnier.Nm 772d6f907dcSJoerg Wunschoutputs the account details in a more human readable form. 7734731d076SDima DorfmanIf the 7744731d076SDima Dorfman.Fl 7 7754731d076SDima Dorfmanoption is used, the account details are shown in v7 format. 776d6f907dcSJoerg WunschThe 77708657612SRuslan Ermilov.Fl a 7789fd0dafcSJoerg Wunschoption lists all users currently on file. 779466c257cSDima DorfmanUsing 780466c257cSDima Dorfman.Fl F 781466c257cSDima Dorfmanforces 782466c257cSDima Dorfman.Nm 783466c257cSDima Dorfmanto print the details of an account even if it does not exist. 7849fd0dafcSJoerg Wunsch.Pp 7859fd0dafcSJoerg WunschThe command 78677fd0356SMateusz Piotrowski.Cm usernext 7879fd0dafcSJoerg Wunschreturns the next available user and group ids separated by a colon. 7889fd0dafcSJoerg WunschThis is normally of interest only to interactive scripts or front-ends 7899fd0dafcSJoerg Wunschthat use 790e97407b4SRuslan Ermilov.Nm . 791d6f907dcSJoerg Wunsch.Sh GROUP OPTIONS 792d6f907dcSJoerg WunschThe 79308657612SRuslan Ermilov.Fl C 794d6f907dcSJoerg Wunschand 79508657612SRuslan Ermilov.Fl q 7969fd0dafcSJoerg Wunschoptions (explained at the start of the previous section) are available 7979fd0dafcSJoerg Wunschwith the group manipulation commands. 798d6f907dcSJoerg WunschOther common options to all group-related commands are: 7999fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers" 8001e4d5cf1SDevin Teske.It Oo Fl n Oc Ar name 8011e4d5cf1SDevin TeskeRequired unless 8021e4d5cf1SDevin Teske.Fl g Ar gid 8031e4d5cf1SDevin Teskeis given. 8041dcc6ec7SPhilippe CharnierSpecify the group name. 8051e4d5cf1SDevin TeskeIn the case of 80677fd0356SMateusz Piotrowski.Cm groupmod 8071e4d5cf1SDevin Teskecan be a gid. 808d6f907dcSJoerg Wunsch.It Fl g Ar gid 8091e4d5cf1SDevin TeskeRequired if 8101e4d5cf1SDevin Teske.Ar name 8111e4d5cf1SDevin Teskeis not given. 8121dcc6ec7SPhilippe CharnierSpecify the group numeric id. 8131e4d5cf1SDevin TeskeIn the case of 81477fd0356SMateusz Piotrowski.Cm groupmod 8151e4d5cf1SDevin Teskeif paired with 8161e4d5cf1SDevin Teske.Ar name , 8171e4d5cf1SDevin Teskechanges the numeric id of the named group. 818d6f907dcSJoerg Wunsch.Pp 8199fd0dafcSJoerg WunschAs with the account name and id fields, you will usually only need 8209fd0dafcSJoerg Wunschto supply one of these, as the group name implies the uid and vice 8219fd0dafcSJoerg Wunschversa. 8229fd0dafcSJoerg WunschYou will only need to use both when setting a specific group id 8239fd0dafcSJoerg Wunschagainst a new group or when changing the uid of an existing group. 8247ecd7a42SJoseph Koshy.It Fl M Ar memberlist 8259fd0dafcSJoerg WunschThis option provides an alternative way to add existing users to a 82677fd0356SMateusz Piotrowskinew group 82777fd0356SMateusz Piotrowski.Pq in Cm groupadd 82877fd0356SMateusz Piotrowskior replace an existing membership list 82977fd0356SMateusz Piotrowski.Pq in Cm groupmod . 8309fd0dafcSJoerg Wunsch.Ar memberlist 8319fd0dafcSJoerg Wunschis a comma separated list of valid and existing user names or uids. 8329fd0dafcSJoerg Wunsch.It Fl m Ar newmembers 8339fd0dafcSJoerg WunschSimilar to 83408657612SRuslan Ermilov.Fl M , 8359fd0dafcSJoerg Wunschthis option allows the 8369fd0dafcSJoerg Wunsch.Em addition 837137db389SSteve Priceof existing users to a group without replacing the existing list of 8389fd0dafcSJoerg Wunschmembers. 839137db389SSteve PriceLogin names or user ids may be used, and duplicate users are 840137db389SSteve Pricesilently eliminated. 841bc991a6dSSean Farley.It Fl d Ar oldmembers 842bc991a6dSSean FarleySimilar to 843bc991a6dSSean Farley.Fl M , 844bc991a6dSSean Farleythis option allows the 845bc991a6dSSean Farley.Em deletion 846bc991a6dSSean Farleyof existing users from a group without replacing the existing list of 847bc991a6dSSean Farleymembers. 848bc991a6dSSean FarleyLogin names or user ids may be used, and duplicate users are 849bc991a6dSSean Farleysilently eliminated. 850d6f907dcSJoerg Wunsch.El 851d6f907dcSJoerg Wunsch.Pp 85277fd0356SMateusz Piotrowski.Cm groupadd 853d6f907dcSJoerg Wunschalso has a 85408657612SRuslan Ermilov.Fl o 855137db389SSteve Priceoption that allows allocation of an existing group id to a new group. 8561e4d5cf1SDevin TeskeThe default action is to reject an attempt to add a group, 8571e4d5cf1SDevin Teskeand this option overrides the check for duplicate group ids. 858d6f907dcSJoerg WunschThere is rarely any need to duplicate a group id. 859d6f907dcSJoerg Wunsch.Pp 860d6f907dcSJoerg WunschThe 86177fd0356SMateusz Piotrowski.Cm groupmod 862137db389SSteve Pricecommand adds one additional option: 8639fd0dafcSJoerg Wunsch.Bl -tag -width "-m newmembers" 8641e4d5cf1SDevin Teske.It Fl l Ar newname 865d6f907dcSJoerg WunschThis option allows changing of an existing group name to 86677fd0356SMateusz Piotrowski.Ar newname . 8671e4d5cf1SDevin TeskeThe new name must not already exist, 8681e4d5cf1SDevin Teskeand any attempt to duplicate an existing group 869d6f907dcSJoerg Wunschname will be rejected. 870d6f907dcSJoerg Wunsch.El 871d6f907dcSJoerg Wunsch.Pp 872d6f907dcSJoerg WunschOptions for 87377fd0356SMateusz Piotrowski.Cm groupshow 874d6f907dcSJoerg Wunschare the same as for 87577fd0356SMateusz Piotrowski.Cm usershow , 876d6f907dcSJoerg Wunschwith the 87708657612SRuslan Ermilov.Fl g Ar gid 878d6f907dcSJoerg Wunschreplacing 87908657612SRuslan Ermilov.Fl u Ar uid 880d6f907dcSJoerg Wunschto specify the group id. 8814731d076SDima DorfmanThe 8824731d076SDima Dorfman.Fl 7 8834731d076SDima Dorfmanoption does not apply to the 88477fd0356SMateusz Piotrowski.Cm groupshow 8854731d076SDima Dorfmancommand. 886d6f907dcSJoerg Wunsch.Pp 8879fd0dafcSJoerg WunschThe command 88877fd0356SMateusz Piotrowski.Cm groupnext 8899fd0dafcSJoerg Wunschreturns the next available group id on standard output. 890e468afb4SDima Dorfman.Sh USER LOCKING 891490d5836SPhilippe CharnierThe 892490d5836SPhilippe Charnier.Nm 893490d5836SPhilippe Charnierutility 894e468afb4SDima Dorfmansupports a simple password locking mechanism for users; it works by 895e468afb4SDima Dorfmanprepending the string 896e468afb4SDima Dorfman.Ql *LOCKED* 897e468afb4SDima Dorfmanto the beginning of the password field in 89877fd0356SMateusz Piotrowski.Xr master.passwd 5 899e468afb4SDima Dorfmanto prevent successful authentication. 900e468afb4SDima Dorfman.Pp 901e468afb4SDima DorfmanThe 90277fd0356SMateusz Piotrowski.Cm lock 903e468afb4SDima Dorfmanand 90477fd0356SMateusz Piotrowski.Cm unlock 905e468afb4SDima Dorfmancommands take a user name or uid of the account to lock or unlock, 90607bfccd7SRuslan Ermilovrespectively. 90707bfccd7SRuslan ErmilovThe 90808657612SRuslan Ermilov.Fl V , 90908657612SRuslan Ermilov.Fl C , 910e468afb4SDima Dorfmanand 91108657612SRuslan Ermilov.Fl q 912e468afb4SDima Dorfmanoptions as described above are accepted by these commands. 91359a3c79dSRuslan Ermilov.Sh NOTES 91459a3c79dSRuslan ErmilovFor a summary of options available with each command, you can use 91559a3c79dSRuslan Ermilov.Dl pw [command] help 91659a3c79dSRuslan ErmilovFor example, 91759a3c79dSRuslan Ermilov.Dl pw useradd help 91877fd0356SMateusz Piotrowskilists all available options for the 91977fd0356SMateusz Piotrowski.Cm useradd 92077fd0356SMateusz Piotrowskioperation. 92159a3c79dSRuslan Ermilov.Pp 92259a3c79dSRuslan ErmilovThe 92359a3c79dSRuslan Ermilov.Nm 92459a3c79dSRuslan Ermilovutility allows 8-bit characters in the passwd GECOS field (user's full name, 92559a3c79dSRuslan Ermilovoffice, work and home phone number subfields), but disallows them in 92659a3c79dSRuslan Ermilovuser login and group names. 92759a3c79dSRuslan ErmilovUse 8-bit characters with caution, as connection to the Internet will 92859a3c79dSRuslan Ermilovrequire that your mail transport program supports 8BITMIME, and will 92959a3c79dSRuslan Ermilovconvert headers containing 8-bit characters to 7-bit quoted-printable 93059a3c79dSRuslan Ermilovformat. 93159a3c79dSRuslan Ermilov.Xr sendmail 8 93259a3c79dSRuslan Ermilovdoes support this. 93359a3c79dSRuslan ErmilovUse of 8-bit characters in the GECOS field should be used in 93459a3c79dSRuslan Ermilovconjunction with the user's default locale and character set 93559a3c79dSRuslan Ermilovand should not be implemented without their use. 93659a3c79dSRuslan ErmilovUsing 8-bit characters may also affect other 93759a3c79dSRuslan Ermilovprograms that transmit the contents of the GECOS field over the 93859a3c79dSRuslan ErmilovInternet, such as 93959a3c79dSRuslan Ermilov.Xr fingerd 8 , 94059a3c79dSRuslan Ermilovand a small number of TCP/IP clients, such as IRC, where full names 94159a3c79dSRuslan Ermilovspecified in the passwd file may be used by default. 94259a3c79dSRuslan Ermilov.Pp 94359a3c79dSRuslan ErmilovThe 94459a3c79dSRuslan Ermilov.Nm 94559a3c79dSRuslan Ermilovutility writes a log to the 94659a3c79dSRuslan Ermilov.Pa /var/log/userlog 94759a3c79dSRuslan Ermilovfile when actions such as user or group additions or deletions occur. 94859a3c79dSRuslan ErmilovThe location of this logfile can be changed in 94959a3c79dSRuslan Ermilov.Xr pw.conf 5 . 95059a3c79dSRuslan Ermilov.Sh FILES 95159a3c79dSRuslan Ermilov.Bl -tag -width /etc/master.passwd.new -compact 95259a3c79dSRuslan Ermilov.It Pa /etc/master.passwd 95359a3c79dSRuslan ErmilovThe user database 95459a3c79dSRuslan Ermilov.It Pa /etc/passwd 95559a3c79dSRuslan ErmilovA Version 7 format password file 95659a3c79dSRuslan Ermilov.It Pa /etc/login.conf 95759a3c79dSRuslan ErmilovThe user capabilities database 95859a3c79dSRuslan Ermilov.It Pa /etc/group 95959a3c79dSRuslan ErmilovThe group database 96059a3c79dSRuslan Ermilov.It Pa /etc/pw.conf 96159a3c79dSRuslan ErmilovPw default options file 96259a3c79dSRuslan Ermilov.It Pa /var/log/userlog 96359a3c79dSRuslan ErmilovUser/group modification logfile 96459a3c79dSRuslan Ermilov.El 9659b8a603eSWarren Block.Sh EXAMPLES 9669b8a603eSWarren BlockAdd new user Glurmo Smith (gsmith). 9679b8a603eSWarren BlockA gsmith login group is created if not already present. 9689b8a603eSWarren BlockThe login shell is set to 9699b8a603eSWarren Block.Xr csh 1 . 9709b8a603eSWarren BlockA new home directory at 9719b8a603eSWarren Block.Pa /home/gsmith 9729b8a603eSWarren Blockis created if it does not already exist. 9739b8a603eSWarren BlockFinally, a random password is generated and displayed: 9749b8a603eSWarren Block.Bd -literal -offset indent 9759b8a603eSWarren Blockpw useradd -n gsmith -c "Glurmo Smith" -s /bin/csh -m -w random 9769b8a603eSWarren Block.Ed 977bb00e549SWarren Block.Pp 978bb00e549SWarren BlockDelete the gsmith user and their home directory, including contents. 979bb00e549SWarren Block.Bd -literal -offset indent 980bb00e549SWarren Blockpw userdel -n gsmith -r 981bb00e549SWarren Block.Ed 98260c81cf1SBenedict Reuschling.Pp 98360c81cf1SBenedict ReuschlingAdd the existing user jsmith to the wheel group, 98460c81cf1SBenedict Reuschlingin addition to the other groups jsmith is already a member of. 98560c81cf1SBenedict Reuschling.Bd -literal -offset indent 98660c81cf1SBenedict Reuschlingpw groupmod wheel -m jsmith 98760c81cf1SBenedict Reuschling.Ed 988a866e170SRuslan Ermilov.Sh EXIT STATUS 989490d5836SPhilippe CharnierThe 990490d5836SPhilippe Charnier.Nm 991490d5836SPhilippe Charnierutility returns EXIT_SUCCESS on successful operation, otherwise 992137db389SSteve Price.Nm 993137db389SSteve Pricereturns one of the 9949fd0dafcSJoerg Wunschfollowing exit codes defined by 9959fd0dafcSJoerg Wunsch.Xr sysexits 3 9969fd0dafcSJoerg Wunschas follows: 9979fd0dafcSJoerg Wunsch.Bl -tag -width xxxx 9989fd0dafcSJoerg Wunsch.It EX_USAGE 9999fd0dafcSJoerg Wunsch.Bl -bullet -compact 10009fd0dafcSJoerg Wunsch.It 10011dcc6ec7SPhilippe CharnierCommand line syntax errors (invalid keyword, unknown option). 10029fd0dafcSJoerg Wunsch.El 10039fd0dafcSJoerg Wunsch.It EX_NOPERM 10049fd0dafcSJoerg Wunsch.Bl -bullet -compact 10059fd0dafcSJoerg Wunsch.It 10069fd0dafcSJoerg WunschAttempting to run one of the update modes as non-root. 10079fd0dafcSJoerg Wunsch.El 10089fd0dafcSJoerg Wunsch.It EX_OSERR 10099fd0dafcSJoerg Wunsch.Bl -bullet -compact 10109fd0dafcSJoerg Wunsch.It 10119fd0dafcSJoerg WunschMemory allocation error. 10129fd0dafcSJoerg Wunsch.It 10139fd0dafcSJoerg WunschRead error from password file descriptor. 10149fd0dafcSJoerg Wunsch.El 10159fd0dafcSJoerg Wunsch.It EX_DATAERR 10169fd0dafcSJoerg Wunsch.Bl -bullet -compact 10179fd0dafcSJoerg Wunsch.It 10189fd0dafcSJoerg WunschBad or invalid data provided or missing on the command line or 1019137db389SSteve Pricevia the password file descriptor. 10209fd0dafcSJoerg Wunsch.It 10219fd0dafcSJoerg WunschAttempted to remove, rename root account or change its uid. 10229fd0dafcSJoerg Wunsch.El 10239fd0dafcSJoerg Wunsch.It EX_OSFILE 10249fd0dafcSJoerg Wunsch.Bl -bullet -compact 10259fd0dafcSJoerg Wunsch.It 10269fd0dafcSJoerg WunschSkeleton directory is invalid or does not exist. 10279fd0dafcSJoerg Wunsch.It 10289fd0dafcSJoerg WunschBase home directory is invalid or does not exist. 10299fd0dafcSJoerg Wunsch.It 1030137db389SSteve PriceInvalid or non-existent shell specified. 10319fd0dafcSJoerg Wunsch.El 10329fd0dafcSJoerg Wunsch.It EX_NOUSER 10339fd0dafcSJoerg Wunsch.Bl -bullet -compact 10349fd0dafcSJoerg Wunsch.It 10359fd0dafcSJoerg WunschUser, user id, group or group id specified does not exist. 10369fd0dafcSJoerg Wunsch.It 1037137db389SSteve PriceUser or group recorded, added, or modified unexpectedly disappeared. 10389fd0dafcSJoerg Wunsch.El 10399fd0dafcSJoerg Wunsch.It EX_SOFTWARE 10409fd0dafcSJoerg Wunsch.Bl -bullet -compact 10419fd0dafcSJoerg Wunsch.It 10429fd0dafcSJoerg WunschNo more group or user ids available within specified range. 10439fd0dafcSJoerg Wunsch.El 10449fd0dafcSJoerg Wunsch.It EX_IOERR 10459fd0dafcSJoerg Wunsch.Bl -bullet -compact 10469fd0dafcSJoerg Wunsch.It 10479fd0dafcSJoerg WunschUnable to rewrite configuration file. 10489fd0dafcSJoerg Wunsch.It 10499fd0dafcSJoerg WunschError updating group or user database files. 10509fd0dafcSJoerg Wunsch.It 10519fd0dafcSJoerg WunschUpdate error for passwd or group database files. 10529fd0dafcSJoerg Wunsch.El 10539fd0dafcSJoerg Wunsch.It EX_CONFIG 10549fd0dafcSJoerg Wunsch.Bl -bullet -compact 10559fd0dafcSJoerg Wunsch.It 10569fd0dafcSJoerg WunschNo base home directory configured. 10579fd0dafcSJoerg Wunsch.El 10589fd0dafcSJoerg Wunsch.El 1059d6f907dcSJoerg Wunsch.Sh SEE ALSO 1060d6f907dcSJoerg Wunsch.Xr chpass 1 , 1061053375e8SMike Pritchard.Xr passwd 1 , 1062eebbeceeSLukas Ertl.Xr umask 2 , 1063d6f907dcSJoerg Wunsch.Xr group 5 , 1064bfd34a4aSWolfram Schneider.Xr login.conf 5 , 1065053375e8SMike Pritchard.Xr passwd 5 , 1066053375e8SMike Pritchard.Xr pw.conf 5 , 1067d6f907dcSJoerg Wunsch.Xr pwd_mkdb 8 , 1068053375e8SMike Pritchard.Xr vipw 8 1069d6f907dcSJoerg Wunsch.Sh HISTORY 1070490d5836SPhilippe CharnierThe 1071490d5836SPhilippe Charnier.Nm 1072490d5836SPhilippe Charnierutility was written to mimic many of the options used in the SYSV 1073d6f907dcSJoerg Wunsch.Em shadow 10749fd0dafcSJoerg Wunschsupport suite, but is modified for passwd and group fields specific to 1075053375e8SMike Pritchardthe 1076053375e8SMike Pritchard.Bx 4.4 10779fd0dafcSJoerg Wunschoperating system, and combines all of the major elements 10789fd0dafcSJoerg Wunschinto a single command. 1079