1.\" $OpenBSD: useradd.8,v 1.35 2016/11/29 03:59:31 jsg Exp $ 2.\" $NetBSD: useradd.8,v 1.26 2003/02/25 10:36:21 wiz Exp $ 3.\" 4.\" Copyright (c) 1999 Alistair G. Crooks. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. The name of the author may not be used to endorse or promote 15.\" products derived from this software without specific prior written 16.\" permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29.\" 30.\" 31.Dd $Mdocdate: November 29 2016 $ 32.Dt USERADD 8 33.Os 34.Sh NAME 35.Nm useradd 36.Nd add a user to the system 37.Sh SYNOPSIS 38.Nm useradd 39.Fl D 40.Op Fl b Ar base-directory 41.Op Fl e Ar expiry-time 42.Op Fl f Ar inactive-time 43.Op Fl g Ar gid | name | Cm =uid 44.Op Fl k Ar skel-directory 45.Op Fl L Ar login-class 46.Op Fl r Ar low Ns .. Ns Ar high 47.Op Fl s Ar shell 48.Nm useradd 49.Op Fl mov 50.Op Fl b Ar base-directory 51.Op Fl c Ar comment 52.Op Fl d Ar home-directory 53.Op Fl e Ar expiry-time 54.Op Fl f Ar inactive-time 55.Op Fl G Ar secondary-group Ns Op , Ns Ar group , Ns ... 56.Op Fl g Ar gid | name | Cm =uid 57.Op Fl k Ar skel-directory 58.Op Fl L Ar login-class 59.Op Fl p Ar password 60.Op Fl r Ar low Ns .. Ns Ar high 61.Op Fl s Ar shell 62.Op Fl u Ar uid 63.Ar user 64.Sh DESCRIPTION 65The 66.Nm useradd 67utility adds a user to the system, creating and 68populating a home directory if necessary. 69Any skeleton files will be provided 70for the new user if they exist in the 71.Ar skel-directory 72directory (see the 73.Fl k 74option). 75Default values for 76the base directory, 77the time of password expiry, 78the time of account expiry, 79primary group, 80the skeleton directory, 81the range from which the UID will be allocated, 82and default login shell 83can be provided in the 84.Pa /etc/usermgmt.conf 85file, which, if running as root, is created using the built-in defaults if 86it does not exist. 87.Pp 88The first form of the command shown above (using the 89.Fl D 90option) 91sets and displays the defaults for the 92.Nm 93utility. 94.Bl -tag -width Ds 95.It Fl b Ar base-directory 96Sets the base directory. 97This is the directory to which the user directory is added, 98which will be created if the 99.Fl m 100option is specified and no 101.Fl d 102option is specified. 103.It Fl D 104Without any further options, 105.Fl D 106will show the current defaults which 107will be used by the 108.Nm 109utility. 110Together with one of the options shown for the first version 111of the command, 112.Fl D 113will set the default to be the new value. 114See 115.Xr usermgmt.conf 5 116for more information. 117.It Fl e Ar expiry-time 118Sets the default time at which new accounts will expire. 119It should be entered in the form 120.Dq month day year , 121where month is the month name (the first three characters are 122sufficient), day is the day of the month, and year is the year. 123Time in seconds since the Epoch (UTC) is also valid. 124A value of 0 can be used to disable this feature. 125.It Fl f Ar inactive-time 126Sets the time at which passwords of new accounts will expire. 127Also see the 128.Fl e 129option above. 130.It Fl g Ar gid | name | Cm =uid 131Sets the default group for new users. 132.It Fl k Ar skel-directory 133Sets the skeleton directory in which to find files with 134which to populate new users' home directories. 135.It Fl L Ar login-class 136Sets the default login class for new users. 137See 138.Xr login.conf 5 139for more information on user login classes. 140.It Xo 141.Fl r Ar low Ns .. Ns Ar high 142.Xc 143Sets the low and high bounds of UID ranges for new users. 144A new user can only be created if there are UIDs which can be assigned 145from one of the free ranges. 146.It Fl s Ar shell 147Sets the default login shell for new users. 148.El 149.Pp 150In the second form of the command, 151after setting any defaults, and then reading values from 152.Pa /etc/usermgmt.conf , 153the following command line options are processed: 154.Bl -tag -width Ds 155.It Fl b Ar base-directory 156Sets the base directory name, in which the user's new home 157directory will be created, should the 158.Fl m 159option be specified. 160.It Fl c Ar comment 161Sets the comment field (also, for historical reasons known as the 162GECOS field) which will be added for the user, and typically will include 163the user's full name and, perhaps, contact information for the user. 164.It Fl d Ar home-directory 165Sets the home directory which will be created and populated for the user, 166should the 167.Fl m 168option be specified. 169.It Fl e Ar expiry-time 170Sets the time at which the user account will expire. 171It should be entered in the form 172.Dq month day year , 173where month is the month name (the first three characters are 174sufficient), day is the day of the month, and year is the year. 175Time in seconds since the Epoch (UTC) is also valid. 176A value of 0 can be used to disable this feature. 177See 178.Xr passwd 5 179for more details. 180.It Fl f Ar inactive-time 181Sets the time at which the current password will expire. 182Also see the 183.Fl e 184option above. 185.It Fl G Ar secondary-group Ns Op , Ns Ar group , Ns ... 186Sets the secondary groups to which the user will be added in the 187.Pa /etc/group 188file. 189.It Fl g Ar gid | name | Cm =uid 190Gives the group name or identifier to be used for the new user's primary group. 191If this is the special string 192.Cm =uid , 193then a UID and GID will be picked which are both unique 194and the same, and a line added to 195.Pa /etc/group 196to describe the new group. 197.It Fl k Ar skel-directory 198Gives the skeleton directory in which to find files 199with which to populate the new user's home directory. 200.It Fl L Ar login-class 201This option sets the login class for the user being created. 202See 203.Xr login.conf 5 204for more information on user login classes. 205.It Fl m 206Create a new home directory for the new user. 207.It Fl o 208Allow the new user to have a UID which is already in use for another user. 209.It Fl p Ar password 210Specifies a password encrypted with 211.Xr encrypt 1 212for the new user. 213This password can then be changed by using the 214.Xr chpass 1 215utility. 216If this option is not specified, and no default exists in 217.Pa /etc/usermgmt.conf , 218the account will be disabled by default. 219.It Fl s Ar shell 220Specifies the login shell for the new user. 221.It Fl u Ar uid 222Specifies a UID for the new user. 223Boundaries for this value can be preset for all users 224by using the 225.Ar range 226field in the 227.Pa /etc/usermgmt.conf 228file. 229.It Fl v 230Enables verbose mode - explain the commands as they are executed. 231.El 232.Pp 233Once the information has been verified, 234.Nm 235uses 236.Xr pwd_mkdb 8 237to update the user database. 238This is run in the background and, 239at very large sites, could take several minutes. 240Until this update is completed, the password file is unavailable for other 241updates and the new information is not available to programs. 242.Sh FILES 243.Bl -tag -width /etc/usermgmt.conf -compact 244.It Pa /etc/usermgmt.conf 245.It Pa /etc/skel/* 246.It Pa /etc/login.conf 247.El 248.Sh EXIT STATUS 249.Ex -std useradd 250.Sh SEE ALSO 251.Xr chpass 1 , 252.Xr group 5 , 253.Xr login.conf 5 , 254.Xr passwd 5 , 255.Xr usermgmt.conf 5 , 256.Xr pwd_mkdb 8 , 257.Xr user 8 , 258.Xr userdel 8 , 259.Xr usermod 8 260.Sh STANDARDS 261Other implementations of the 262.Nm useradd 263utility use the 264.Ar inactive-time 265parameter to refer to the maximum number of days allowed between logins (this 266is used to lock "stale" accounts that have not been used for a period of time). 267However, on 268.Ox 269systems this parameter refers instead to the password change time. 270This is due to differences in the 271.Xr passwd 5 272database compared to other operating systems. 273.Sh HISTORY 274The 275.Nm 276utility first appeared in 277.Ox 2.7 . 278.Sh AUTHORS 279The 280.Nm 281utility was written by 282.An Alistair G. Crooks Aq Mt agc@NetBSD.org . 283