1.\" $NetBSD: useradd.8,v 1.18 2002/06/01 09:21:21 wiz Exp $ */ 2.\" 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. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by Alistair G. Crooks. 17.\" 4. The name of the author may not be used to endorse or promote 18.\" products derived from this software without specific prior written 19.\" permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 22.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 25.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 27.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32.\" 33.\" 34.Dd September 5, 2001 35.Dt USERADD 8 36.Os 37.Sh NAME 38.Nm useradd 39.Nd add a user to the system 40.Sh SYNOPSIS 41.Nm "" 42.Fl D 43.Op Fl b Ar base-dir 44.Op Fl e Ar expiry-time 45.Op Fl f Ar inactive-time 46.Oo 47.Fl g Ar gid | name | Li =uid Oc 48.Op Fl L Ar login-class 49.Oo 50.Op Fl k Ar skel-dir 51.Fl r Ar low Ns Li .. Ns Ar high 52.Oc 53.Op Fl s Ar shell 54.Nm "" 55.Op Fl mov 56.Op Fl G Ar secondary-group 57.Op Fl b Ar base-dir 58.Op Fl c Ar comment 59.Op Fl d Ar home-dir 60.Op Fl e Ar expiry-time 61.Op Fl f Ar inactive-time 62.Oo 63.Fl g Ar gid | name | Li =uid Oc 64.Op Fl k Ar skel-dir 65.Op Fl L Ar login-class 66.Op Fl p Ar password 67.Oo 68.Fl r Ar low Ns Li .. Ns Ar high 69.Oc 70.Op Fl s Ar shell 71.Op Fl u Ar uid 72.Ar user 73.Sh DESCRIPTION 74The 75.Nm useradd 76utility adds a user to the system, creating and 77populating a home directory if necessary. 78Any skeleton files will be provided 79for the new user if they exist in the 80.Pa /etc/skel 81directory. 82Default values for 83the base directory, 84the time of password expiry, 85seconds until password change, 86primary group, 87the skeleton directory, 88the range from which the uid will be allocated, 89and default login shell 90can be provided in the 91.Pa /etc/usermgmt.conf 92file. 93.Pp 94The first format of the command shown above (utilising the 95.Fl D 96option) 97sets and displays the defaults for the 98.Nm 99utility. 100.Bl -tag -width Ds 101.It Fl D 102without any further options, 103.Fl D 104will show the current defaults which 105will be used by the 106.Nm 107utility. Together with one of the options shown for the first version 108of the command, 109.Fl D 110will set the default to be the new value. See 111.Xr usermgmt.conf 5 112for more information. 113.It Fl b Ar base-dir 114sets the default base directory. This is the directory to which the 115user directory is added, which will be created if the 116.Fl m 117option is specified and no 118.Fl d 119option is specified. 120.It Fl e Ar expiry-time 121sets the default time at which the current password will expire for new 122users. 123It should be entered in the form 124.Dq month day year , 125where month is the month name (the first three characters are 126sufficient), day is the day of the month, and year is the year. Time 127in seconds since the epoch (UTC) is also valid. 128A value of 0 can be used to disable this feature. 129.It Fl f Ar inactive-time 130sets the default time at which new user accounts will expire. 131Also see the 132.Fl e 133option above. 134.It Fl g Ar gid | groupname | Li =uid 135sets the default group for new users. 136.It Fl k Ar skel-dir 137sets the skeleton directory in which to find files with 138which to populate new users' home directories. 139.It Fl L Ar login-class 140sets the default login class for new users. 141See 142.Xr login.conf 5 143for more information on user login classes. 144.It Xo 145.Fl r Ar low Ns Li .. Ns Ar high 146.Xc 147sets the low and high bounds of uid ranges for new users. A new user 148can only be created if there are uids which can be assigned from one 149of the free ranges. 150.It Fl s Ar shell 151sets the default login shell for new users. 152.El 153.Pp 154In the second form of the command, 155after setting any defaults, and then values from that file, 156the command line options are processed: 157.Bl -tag -width Ds 158.It Fl G Ar secondary-group 159is the secondary group to which the user will be added in the 160.Pa /etc/group 161file. 162.It Fl b Ar base-directory 163is the base directory name, in which the user's new home 164directory will be created, should the -m option be specified. 165.It Fl c Ar comment 166is the comment field (also, for historical reasons known as the 167GECOS field) which will be added for the user, and typically will include 168the username, and, perhaps, contact information for the user. 169.It Fl d Ar home-directory 170is the home directory which will be created and populated for the user, 171should the -m option be specified. 172.It Fl e Ar expiry-time 173sets the default time at which the current password will expire for new 174users. 175It should be entered in the form 176.Dq month day year , 177where month is the month name (the first three characters are 178sufficient), day is the day of the month, and year is the year. Time 179in seconds since the epoch (UTC) is also valid. 180A value of 0 can be used to disable this feature. 181See 182.Xr passwd 5 183for more details. 184.It Fl g Ar gid | name | Li =uid 185gives the group name or identifier to be used for the new user's primary group. 186If this is 187.Ql =uid , 188then a uid and gid will be picked which are both unique 189and the same, and a line added to 190.Pa /etc/group 191to describe the new group. 192.It Fl k Ar skeleton directory 193gives the skeleton directory in which to find files 194with which to populate the new user's home directory. 195.It Fl L Ar login-class 196This option sets the login class for the user being created. See 197.Xr login.conf 5 198for more information on user login classes. 199.It Fl m 200create a new home directory for the new user. 201.It Fl o 202allow the new user to have a uid which is already in use for another user. 203.It Fl p Ar password 204specifies an already-encrypted password for the new user. 205This password can then be changed by using the 206.Xr chpass 1 207utility. 208.It Fl s Ar shell 209specifies the login shell for the new user. 210.It Fl u Ar uid 211specifies a uid for the new user. 212Boundaries for this value can be preset for all users 213by using the 214.Ar range 215field in the 216.Pa /etc/usermgmt.conf 217file. 218.It Fl v 219enables verbose mode - explain the commands as they are executed. 220.El 221.Pp 222Once the information has been verified, 223.Nm 224uses 225.Xr pwd_mkdb 8 226to update the user database. This is run in the background, and, 227at very large sites could take several minutes. Until this update 228is completed, the password file is unavailable for other updates 229and the new information is not available to programs. 230.Pp 231The 232.Nm 233utility exits 0 on success, and \*[Gt]0 if an error occurs. 234.Sh FILES 235.Bl -tag -width /etc/usermgmt.conf -compact 236.It Pa /etc/usermgmt.conf 237.It Pa /etc/skel/* 238.It Pa /etc/login.conf 239.El 240.Sh SEE ALSO 241.Xr chpass 1 , 242.Xr group 5 , 243.Xr login.conf 5 , 244.Xr passwd 5 , 245.Xr usermgmt.conf 5 , 246.Xr pwd_mkdb 8 , 247.Xr user 8 , 248.Xr userdel 8 , 249.Xr usermod 8 250.Sh HISTORY 251The 252.Nm 253utility first appeared in 254.Nx 1.5 . 255It is based on the 256.Ar addnerd 257package by the same author. 258.Sh AUTHORS 259The 260.Nm 261utility was written by Alistair G. Crooks (agc@netbsd.org). 262