1*7a3d14ecSjsg.\" $OpenBSD: useradd.8,v 1.35 2016/11/29 03:59:31 jsg Exp $ 26806f038Smillert.\" $NetBSD: useradd.8,v 1.26 2003/02/25 10:36:21 wiz Exp $ 3e02380dbSjakob.\" 4e02380dbSjakob.\" Copyright (c) 1999 Alistair G. Crooks. All rights reserved. 5e02380dbSjakob.\" 6e02380dbSjakob.\" Redistribution and use in source and binary forms, with or without 7e02380dbSjakob.\" modification, are permitted provided that the following conditions 8e02380dbSjakob.\" are met: 9e02380dbSjakob.\" 1. Redistributions of source code must retain the above copyright 10e02380dbSjakob.\" notice, this list of conditions and the following disclaimer. 11e02380dbSjakob.\" 2. Redistributions in binary form must reproduce the above copyright 12e02380dbSjakob.\" notice, this list of conditions and the following disclaimer in the 13e02380dbSjakob.\" documentation and/or other materials provided with the distribution. 14*7a3d14ecSjsg.\" 3. The name of the author may not be used to endorse or promote 15e02380dbSjakob.\" products derived from this software without specific prior written 16e02380dbSjakob.\" permission. 17e02380dbSjakob.\" 18e02380dbSjakob.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19e02380dbSjakob.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20e02380dbSjakob.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21e02380dbSjakob.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22e02380dbSjakob.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23e02380dbSjakob.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24e02380dbSjakob.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25e02380dbSjakob.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26e02380dbSjakob.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27e02380dbSjakob.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28e02380dbSjakob.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29e02380dbSjakob.\" 30e02380dbSjakob.\" 31*7a3d14ecSjsg.Dd $Mdocdate: November 29 2016 $ 32e02380dbSjakob.Dt USERADD 8 338aa50653Sjakob.Os 34e02380dbSjakob.Sh NAME 35e02380dbSjakob.Nm useradd 36e02380dbSjakob.Nd add a user to the system 37e02380dbSjakob.Sh SYNOPSIS 38f1bf55a6Sjakob.Nm useradd 393c76c7c0Smillert.Fl D 400f5c715dSsobrado.Op Fl b Ar base-directory 41e02380dbSjakob.Op Fl e Ar expiry-time 426806f038Smillert.Op Fl f Ar inactive-time 43fadb4645Sschwarze.Op Fl g Ar gid | name | Cm =uid 440f5c715dSsobrado.Op Fl k Ar skel-directory 45496e0d47Sjmc.Op Fl L Ar login-class 46d3f7b840Sschwarze.Op Fl r Ar low Ns .. Ns Ar high 4749c0e608Sjakob.Op Fl s Ar shell 48f1bf55a6Sjakob.Nm useradd 493c76c7c0Smillert.Op Fl mov 500f5c715dSsobrado.Op Fl b Ar base-directory 51e02380dbSjakob.Op Fl c Ar comment 520f5c715dSsobrado.Op Fl d Ar home-directory 53e02380dbSjakob.Op Fl e Ar expiry-time 546806f038Smillert.Op Fl f Ar inactive-time 55d3f7b840Sschwarze.Op Fl G Ar secondary-group Ns Op , Ns Ar group , Ns ... 56fadb4645Sschwarze.Op Fl g Ar gid | name | Cm =uid 570f5c715dSsobrado.Op Fl k Ar skel-directory 583c76c7c0Smillert.Op Fl L Ar login-class 59e02380dbSjakob.Op Fl p Ar password 60d3f7b840Sschwarze.Op Fl r Ar low Ns .. Ns Ar high 61e02380dbSjakob.Op Fl s Ar shell 62e02380dbSjakob.Op Fl u Ar uid 63e02380dbSjakob.Ar user 64e02380dbSjakob.Sh DESCRIPTION 65e02380dbSjakobThe 66e02380dbSjakob.Nm useradd 67e02380dbSjakobutility adds a user to the system, creating and 68e02380dbSjakobpopulating a home directory if necessary. 693c76c7c0SmillertAny skeleton files will be provided 70e02380dbSjakobfor the new user if they exist in the 710f5c715dSsobrado.Ar skel-directory 726806f038Smillertdirectory (see the 736806f038Smillert.Fl k 746806f038Smillertoption). 753c76c7c0SmillertDefault values for 763c76c7c0Smillertthe base directory, 773c76c7c0Smillertthe time of password expiry, 786806f038Smillertthe time of account expiry, 793c76c7c0Smillertprimary group, 80e02380dbSjakobthe skeleton directory, 814fb31a24Sjmcthe range from which the UID will be allocated, 823c76c7c0Smillertand default login shell 833c76c7c0Smillertcan be provided in the 84e02380dbSjakob.Pa /etc/usermgmt.conf 856806f038Smillertfile, which, if running as root, is created using the built-in defaults if 866806f038Smillertit does not exist. 87e02380dbSjakob.Pp 886806f038SmillertThe first form of the command shown above (using the 893c76c7c0Smillert.Fl D 903c76c7c0Smillertoption) 91e02380dbSjakobsets and displays the defaults for the 92e02380dbSjakob.Nm 93e02380dbSjakobutility. 94e02380dbSjakob.Bl -tag -width Ds 950f5c715dSsobrado.It Fl b Ar base-directory 960f5c715dSsobradoSets the base directory. 970f5c715dSsobradoThis is the directory to which the user directory is added, 980f5c715dSsobradowhich will be created if the 990f5c715dSsobrado.Fl m 1000f5c715dSsobradooption is specified and no 1010f5c715dSsobrado.Fl d 1020f5c715dSsobradooption is specified. 103e02380dbSjakob.It Fl D 1040f5c715dSsobradoWithout any further options, 1053c76c7c0Smillert.Fl D 1063c76c7c0Smillertwill show the current defaults which 107e02380dbSjakobwill be used by the 108e02380dbSjakob.Nm 1096806f038Smillertutility. 1106806f038SmillertTogether with one of the options shown for the first version 1113c76c7c0Smillertof the command, 1123c76c7c0Smillert.Fl D 1133c76c7c0Smillertwill set the default to be the new value. 1146806f038SmillertSee 1156806f038Smillert.Xr usermgmt.conf 5 1166806f038Smillertfor more information. 117e02380dbSjakob.It Fl e Ar expiry-time 1180f5c715dSsobradoSets the default time at which new accounts will expire. 1196806f038SmillertIt should be entered in the form 1206806f038Smillert.Dq month day year , 1216806f038Smillertwhere month is the month name (the first three characters are 1226806f038Smillertsufficient), day is the day of the month, and year is the year. 1234dda51ceSjmcTime in seconds since the Epoch (UTC) is also valid. 1246806f038SmillertA value of 0 can be used to disable this feature. 1256806f038Smillert.It Fl f Ar inactive-time 1260f5c715dSsobradoSets the time at which passwords of new accounts will expire. 1276806f038SmillertAlso see the 1286806f038Smillert.Fl e 1296806f038Smillertoption above. 130fadb4645Sschwarze.It Fl g Ar gid | name | Cm =uid 1310f5c715dSsobradoSets the default group for new users. 1320f5c715dSsobrado.It Fl k Ar skel-directory 1330f5c715dSsobradoSets the skeleton directory in which to find files with 1343c76c7c0Smillertwhich to populate new users' home directories. 1353c76c7c0Smillert.It Fl L Ar login-class 1360f5c715dSsobradoSets the default login class for new users. 1376806f038SmillertSee 1383c76c7c0Smillert.Xr login.conf 5 1396806f038Smillertfor more information on user login classes. 1403c76c7c0Smillert.It Xo 141d3f7b840Sschwarze.Fl r Ar low Ns .. Ns Ar high 1423c76c7c0Smillert.Xc 1430f5c715dSsobradoSets the low and high bounds of UID ranges for new users. 1444fb31a24SjmcA new user can only be created if there are UIDs which can be assigned 1454fb31a24Sjmcfrom one of the free ranges. 14649c0e608Sjakob.It Fl s Ar shell 1470f5c715dSsobradoSets the default login shell for new users. 148e02380dbSjakob.El 149e02380dbSjakob.Pp 150e02380dbSjakobIn the second form of the command, 1516806f038Smillertafter setting any defaults, and then reading values from 1526806f038Smillert.Pa /etc/usermgmt.conf , 1536806f038Smillertthe following command line options are processed: 154e02380dbSjakob.Bl -tag -width Ds 155e02380dbSjakob.It Fl b Ar base-directory 1560f5c715dSsobradoSets the base directory name, in which the user's new home 1576806f038Smillertdirectory will be created, should the 1586806f038Smillert.Fl m 1596806f038Smillertoption be specified. 160e02380dbSjakob.It Fl c Ar comment 1610f5c715dSsobradoSets the comment field (also, for historical reasons known as the 162e02380dbSjakobGECOS field) which will be added for the user, and typically will include 1630870f47dSjmcthe user's full name and, perhaps, contact information for the user. 164e02380dbSjakob.It Fl d Ar home-directory 1650f5c715dSsobradoSets the home directory which will be created and populated for the user, 166cbad1914Sjmcshould the 167cbad1914Sjmc.Fl m 168cbad1914Sjmcoption be specified. 1696806f038Smillert.It Fl e Ar expiry-time 1700f5c715dSsobradoSets the time at which the user account will expire. 1716806f038SmillertIt should be entered in the form 1726806f038Smillert.Dq month day year , 1736806f038Smillertwhere month is the month name (the first three characters are 1746806f038Smillertsufficient), day is the day of the month, and year is the year. 1754dda51ceSjmcTime in seconds since the Epoch (UTC) is also valid. 1766806f038SmillertA value of 0 can be used to disable this feature. 177e02380dbSjakobSee 178e02380dbSjakob.Xr passwd 5 179e02380dbSjakobfor more details. 1806806f038Smillert.It Fl f Ar inactive-time 1810f5c715dSsobradoSets the time at which the current password will expire. 1826806f038SmillertAlso see the 1836806f038Smillert.Fl e 1846806f038Smillertoption above. 185d3f7b840Sschwarze.It Fl G Ar secondary-group Ns Op , Ns Ar group , Ns ... 1860f5c715dSsobradoSets the secondary groups to which the user will be added in the 187496e0d47Sjmc.Pa /etc/group 188496e0d47Sjmcfile. 189fadb4645Sschwarze.It Fl g Ar gid | name | Cm =uid 1900f5c715dSsobradoGives the group name or identifier to be used for the new user's primary group. 191fadb4645SschwarzeIf this is the special string 192fadb4645Sschwarze.Cm =uid , 1934fb31a24Sjmcthen a UID and GID will be picked which are both unique 194e02380dbSjakoband the same, and a line added to 195e02380dbSjakob.Pa /etc/group 196e02380dbSjakobto describe the new group. 1970f5c715dSsobrado.It Fl k Ar skel-directory 1980f5c715dSsobradoGives the skeleton directory in which to find files 199e02380dbSjakobwith which to populate the new user's home directory. 2003c76c7c0Smillert.It Fl L Ar login-class 2014fb31a24SjmcThis option sets the login class for the user being created. 2024fb31a24SjmcSee 2033c76c7c0Smillert.Xr login.conf 5 2046806f038Smillertfor more information on user login classes. 205e02380dbSjakob.It Fl m 2060f5c715dSsobradoCreate a new home directory for the new user. 207e02380dbSjakob.It Fl o 2080f5c715dSsobradoAllow the new user to have a UID which is already in use for another user. 209e02380dbSjakob.It Fl p Ar password 2107b0ba352StbSpecifies a password encrypted with 2117b0ba352Stb.Xr encrypt 1 2127b0ba352Stbfor the new user. 213e02380dbSjakobThis password can then be changed by using the 214e02380dbSjakob.Xr chpass 1 215e02380dbSjakobutility. 2166806f038SmillertIf this option is not specified, and no default exists in 2176806f038Smillert.Pa /etc/usermgmt.conf , 2186806f038Smillertthe account will be disabled by default. 219e02380dbSjakob.It Fl s Ar shell 2200f5c715dSsobradoSpecifies the login shell for the new user. 221e02380dbSjakob.It Fl u Ar uid 2220f5c715dSsobradoSpecifies a UID for the new user. 223e02380dbSjakobBoundaries for this value can be preset for all users 224e02380dbSjakobby using the 225e02380dbSjakob.Ar range 226e02380dbSjakobfield in the 227e02380dbSjakob.Pa /etc/usermgmt.conf 2286806f038Smillertfile. 229e02380dbSjakob.It Fl v 2300f5c715dSsobradoEnables verbose mode - explain the commands as they are executed. 231e02380dbSjakob.El 232e02380dbSjakob.Pp 2333c76c7c0SmillertOnce the information has been verified, 2343c76c7c0Smillert.Nm 2353c76c7c0Smillertuses 2363c76c7c0Smillert.Xr pwd_mkdb 8 2374fb31a24Sjmcto update the user database. 2380870f47dSjmcThis is run in the background and, 2390870f47dSjmcat very large sites, could take several minutes. 2404fb31a24SjmcUntil this update is completed, the password file is unavailable for other 2414fb31a24Sjmcupdates and the new information is not available to programs. 242e02380dbSjakob.Sh FILES 243e02380dbSjakob.Bl -tag -width /etc/usermgmt.conf -compact 244e02380dbSjakob.It Pa /etc/usermgmt.conf 2453c76c7c0Smillert.It Pa /etc/skel/* 2463c76c7c0Smillert.It Pa /etc/login.conf 247e02380dbSjakob.El 248741b6f30Sjmc.Sh EXIT STATUS 249741b6f30Sjmc.Ex -std useradd 250e02380dbSjakob.Sh SEE ALSO 251e02380dbSjakob.Xr chpass 1 , 252e02380dbSjakob.Xr group 5 , 253f26c6412Sfgsch.Xr login.conf 5 , 254f26c6412Sfgsch.Xr passwd 5 , 2556806f038Smillert.Xr usermgmt.conf 5 , 2563c76c7c0Smillert.Xr pwd_mkdb 8 , 257e02380dbSjakob.Xr user 8 , 258e02380dbSjakob.Xr userdel 8 , 259f26c6412Sfgsch.Xr usermod 8 2606784aa3eSmillert.Sh STANDARDS 2616784aa3eSmillertOther implementations of the 2626784aa3eSmillert.Nm useradd 2636784aa3eSmillertutility use the 2646784aa3eSmillert.Ar inactive-time 2656784aa3eSmillertparameter to refer to the maximum number of days allowed between logins (this 266a44f4117Sjmcis used to lock "stale" accounts that have not been used for a period of time). 2676784aa3eSmillertHowever, on 2686784aa3eSmillert.Ox 2696784aa3eSmillertsystems this parameter refers instead to the password change time. 2706784aa3eSmillertThis is due to differences in the 2716784aa3eSmillert.Xr passwd 5 2726784aa3eSmillertdatabase compared to other operating systems. 273e02380dbSjakob.Sh HISTORY 274e02380dbSjakobThe 275e02380dbSjakob.Nm 276e02380dbSjakobutility first appeared in 277f88889abSjakob.Ox 2.7 . 278b5667098Smpech.Sh AUTHORS 279e02380dbSjakobThe 280e02380dbSjakob.Nm 2816806f038Smillertutility was written by 28244e68d47Sschwarze.An Alistair G. Crooks Aq Mt agc@NetBSD.org . 283