1 .\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
2 .\" All rights reserved.
3 .\" Copyright (c) 2002-2004 Michael Telahun Makonnen <mtm@FreeBSD.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .Dd September 15, 2012
34 .Nd command for adding new users
39 .Op Fl L Ar login_class
43 .Op Fl g Ar login_group
45 .Op Fl m Ar message_file
52 utility is a shell script, implemented around the
54 command, for adding new users.
55 It creates passwd/group entries, a home directory,
56 copies dotfiles and sends the new user a welcome message.
57 It supports two modes of operation.
58 It may be used interactively
59 at the command line to add one user at a time, or it may be directed
60 to get the list of new users from a file and operate in batch mode
61 without requiring any user interaction.
63 .Bl -tag -width indent
66 The user name is restricted to whatever
69 Generally this means it
70 may contain only lowercase characters or digits but cannot begin with the
75 The reasons for this limit are historical.
76 Given that people have traditionally wanted to break this
77 limit for aesthetic reasons, it has never been of great importance to break
78 such a basic fundamental parameter in
85 world; people have done this and it works, but you will have problems
86 with any precompiled programs, or source that assumes the 8-character
87 name limit, such as NIS.
88 The NIS protocol mandates an 8-character username.
89 If you need a longer login name for e-mail addresses,
90 you can define an alias in
91 .Pa /etc/mail/aliases .
93 This is typically known as the gecos field and usually contains
95 Additionally, it may contain a comma separated
96 list of values such as office number and work and home phones.
98 name contains an ampersand it will be replaced by the capitalized
99 login name when displayed by other programs.
102 character is not allowed.
106 argument is supplied only valid shells from the shell database
110 either the base name or the full path of the shell may be supplied.
112 Automatically generated or your choice.
113 It must be less than 32000.
114 .It "GID/login group"
115 Automatically generated or your choice.
116 It must be less than 32000.
118 You may choose an empty password, disable the password, use a
119 randomly generated password or specify your own plaintext password,
120 which will be encrypted before being stored in the user database.
123 Perhaps you are missing what
125 be done with this scheme that falls apart
126 with most other schemes.
127 With each user in their own group,
128 they can safely run with a umask of 002 instead of the usual 022
129 and create files in their home directory
130 without worrying about others being able to change them.
132 For a shared area you create a separate UID/GID, you place each person
133 that should be able to access this area into that new group.
135 This model of UID/GID administration allows far greater flexibility than lumping
136 users into groups and having to muck with the umask when working in a shared
139 I have been using this model for almost 10 years and found that it works
140 for most situations, and has never gotten in the way.
145 utility reads its configuration information from
146 .Pa /etc/adduser.conf .
147 If this file does not exist, it will use predefined defaults.
148 While this file may be edited by hand,
149 the safer option is to use the
151 command line argument.
154 will start interactive input, save the answers to its prompts in
155 .Pa /etc/adduser.conf ,
156 and promptly exit without modifying the user
158 Options specified on the command line will take precedence over
159 any values saved in this file.
161 .Bl -tag -width indent
163 Create new configuration file and exit.
164 This option is mutually exclusive with the
167 .It Fl d Ar partition
169 Default partition, under which all user directories
173 partition is considered special.
176 script will not create and populate a home directory by that name.
178 by default it attempts to create a home directory.
180 Do not attempt to create the home directory.
183 This option will lock the account by prepending the string
185 to the password field.
186 The account may be unlocked
187 by the super-user with the
191 .D1 Nm pw Cm unlock Op Ar name | uid
193 Get the list of accounts to create from
199 then get the list from standard input.
200 If this option is specified,
202 will operate in batch mode and will not seek any user input.
203 If an error is encountered while processing an account, it will write a
204 message to standard error and move to the next account.
206 of the input file is described below.
207 .It Fl g Ar login_group
209 if no login group is specified,
210 it is assumed to be the same as the username.
215 Space-separated list of additional groups.
216 This option allows the user to specify additional groups to add users to.
217 The user is a member of these groups in addition to their login group.
219 Print a summary of options and exit.
220 .It Fl k Ar directory
224 directory of new users;
228 .It Fl L Ar login_class
229 Set default login class.
231 Send new users a welcome message from
233 Specifying a value of
237 causes no message to be sent to new users.
238 Please note that the message
239 file can reference the internal variables of the
243 Create the home directory with permissions set to
246 Do not read the default configuration file.
248 Minimal user feedback.
249 In particular, the random password will not be echoed to
252 Default shell for new users.
255 argument may be the base name of the shell or the full path.
258 argument is supplied the shell must exist in
260 or be the special shell
262 to be considered a valid shell.
264 The existence or validity of the specified shell will not be checked.
273 utility allows the user to specify what type of password to create.
276 argument may have one of the following values:
277 .Bl -tag -width ".Cm random"
279 Disable the password.
280 Instead of an encrypted string, the password field will contain a single
283 The user may not log in until the super-user
284 manually enables the password.
286 Use an empty string as the password.
288 Use a user-supplied string as the password.
290 the user will be prompted for the password.
292 last (10th) field in the line is assumed to be the password.
294 Generate a random string and use it as a password.
295 The password will be echoed to standard output.
296 In addition, it will be available for inclusion in the message file in the
304 option is used, the account information must be stored in a specific
306 All empty lines or lines beginning with a
309 All other lines must contain ten colon
311 separated fields as described below.
312 Command line options do not take precedence
313 over values in the fields.
314 Only the password field may contain a
316 character as part of the string.
319 .D1 Ar name : uid : gid : class : change : expire : gecos : home_dir : shell : password
321 .Bl -tag -width ".Ar password"
324 This field may not be empty.
326 Numeric login user ID.
327 If this field is left empty, it will be automatically generated.
329 Numeric primary group ID.
330 If this field is left empty, a group with the
331 same name as the user name will be created and its GID will be used
335 This field may be left empty.
338 This field denotes the password change date for the account.
339 The format of this field is the same as the format of the
344 .Ar dd Ns - Ns Ar mmm Ns - Ns Ar yy Ns Op Ar yy ,
349 is for the month in numeric or alphabetical format:
355 is the four or two digit year.
356 To denote a time relative to the current date the format is:
357 .No + Ns Ar n Ns Op Ar mhdwoy ,
360 denotes a number, followed by the minutes, hours, days, weeks,
361 months or years after which the password must be changed.
362 This field may be left empty to turn it off.
365 This field denotes the expiry date of the account.
366 The account may not be used after the specified date.
367 The format of this field is the same as that for password ageing.
368 This field may be left empty to turn it off.
370 Full name and other extra information about the user.
373 If this field is left empty, it will be automatically
374 created by appending the username to the home partition.
377 home directory is considered special and
378 is understood to mean that no home directory is to be
379 created for the user.
382 This field should contain either the base name or
383 the full path to a valid login shell.
386 This field should contain a plaintext string, which will
387 be encrypted before being placed in the user database.
388 If the password type is
390 and this field is empty, it is assumed the account will have an empty password.
391 If the password type is
395 empty, its contents will be used
397 This field will be ignored if the
399 option is used with a
404 Be careful not to terminate this field with a closing
406 because it will be treated as part of the password.
409 .Bl -tag -width ".Pa /etc/adduser.message" -compact
410 .It Pa /etc/master.passwd
416 .It Pa /etc/login.conf
417 login classes database
418 .It Pa /etc/adduser.conf
419 configuration file for
421 .It Pa /etc/adduser.message
424 .It Pa /usr/share/skel
425 skeletal login directory
426 .It Pa /var/log/adduser
452 This manual page and the original script, in Perl, was written by
453 .An Wolfram Schneider Aq wosch@FreeBSD.org .
454 The replacement script, written as a Bourne
455 shell script with some enhancements, and the man page modification that
456 came with it were done by
457 .An Mike Makonnen Aq mtm@identd.net .
461 to correctly expand variables such as
465 in the message sent to new users, it must let the shell evaluate
466 each line of the message file.
467 This means that shell commands can also be embedded in the message file.
470 utility attempts to mitigate the possibility of an attacker using this
471 feature by refusing to evaluate the file if it is not owned and writable
472 only by the root user.
473 In addition, shell special characters and operators will have to be
474 escaped when used in the message file.
476 Also, password ageing and account expiry times are currently settable
477 only in batch mode or when specified in
478 .Pa /etc/adduser.conf .
479 The user should be able to set them in interactive mode as well.