1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry id='useradd.8'>
3 <!-- $Id: useradd.8.xml,v 1.34 2006/05/20 12:11:38 kloczek Exp $ -->
5 <refentrytitle>useradd</refentrytitle>
6 <manvolnum>8</manvolnum>
7 <refmiscinfo class="sectdesc">System Management Commands</refmiscinfo>
10 <refname>useradd</refname>
11 <refpurpose>create a new user or update default new user information</refpurpose>
13 <refsynopsisdiv id='synopsis'>
15 <command>useradd</command>
17 <replaceable>options</replaceable>
19 <arg choice='plain'><replaceable>LOGIN</replaceable></arg>
22 <command>useradd</command>
23 <arg choice='plain'>-D </arg>
26 <command>useradd</command>
27 <arg choice='plain'>-D </arg>
29 <replaceable>options</replaceable>
34 <refsect1 id='description'>
35 <title>DESCRIPTION</title>
37 When invoked without the <option>-D</option> option, the
38 <command>useradd</command> command creates a new user account using
39 the values specified on the command line and the default values from
40 the system. Depending on command line options, the useradd command
41 will update system files and may also create the new user's home
42 directory and copy initial files.
46 <refsect1 id='options'>
47 <title>OPTIONS</title>
48 <para>The options which apply to the <command>useradd</command> command are:
50 <variablelist remap='IP'>
53 <option>-c</option>, <option>--comment</option>
54 <replaceable>COMMENT</replaceable>
58 Any text string. It is generally a short description of the
59 login, and is currently used as the field for the user's full
66 <option>-b</option>, <option>--base-dir</option>
67 <replaceable>BASE_DIR</replaceable>
71 The default base directory for the system if <option>-d</option>
72 dir is not specified. <replaceable>BASE_DIR</replaceable> is
73 concatenated with the account name to define the home directory.
74 If the <option>-m</option> option is not used,
75 <replaceable>BASE_DIR</replaceable> must exist.
81 <option>-d</option>, <option>--home</option>
82 <replaceable>HOME_DIR</replaceable>
86 The new user will be created using
87 <replaceable>HOME_DIR</replaceable> as the value for the user's
88 login directory. The default is to append the
89 <replaceable>LOGIN</replaceable> name to
90 <replaceable>BASE_DIR</replaceable> and use that as the login
91 directory name. The directory <replaceable>HOME_DIR</replaceable>
92 does not have to exist but will not be created if it is missing.
98 <option>-e</option>, <option>--expiredate</option>
99 <replaceable>EXPIRE_DATE</replaceable>
103 The date on which the user account will be disabled. The date is
104 specified in the format <emphasis remap='I'>YYYY-MM-DD</emphasis>.
110 <option>-f</option>, <option>--inactive</option>
111 <replaceable>INACTIVE</replaceable>
115 The number of days after a password expires until the account is
116 permanently disabled. A value of 0 disables the account as soon
117 as the password has expired, and a value of -1 disables the
118 feature. The default value is -1.
124 <option>-g</option>, <option>--gid</option>
125 <replaceable>GROUP</replaceable>
129 The group name or number of the user's initial login group. The
130 group name must exist. A group number must refer to an already
131 existing group. The default group number is 1 or whatever is
132 specified in <filename>/etc/default/useradd</filename>.
138 <option>-G</option>, <option>--groups</option>
139 <replaceable>GROUP1</replaceable>[<emphasis remap='I'>,GROUP2,...</emphasis>[<emphasis remap='I'>,GROUPN</emphasis>]]]
143 A list of supplementary groups which the user is also a member
144 of. Each group is separated from the next by a comma, with no
145 intervening whitespace. The groups are subject to the same
146 restrictions as the group given with the <option>-g</option>
147 option. The default is for the user to belong only to the
153 <term><option>-h</option>, <option>--help</option></term>
155 <para>Display help message and exit.</para>
160 <option>-m</option>, <option>--create-home</option>
164 The user's home directory will be created if it does not exist.
165 The files contained in <replaceable>SKEL_DIR</replaceable> will
166 be copied to the home directory if the <option>-k</option>
167 option is used, otherwise the files contained in
168 <filename>/etc/skel</filename> will be used instead. Any
169 directories contained in <replaceable>SKEL_DIR</replaceable> or
170 <filename>/etc/skel</filename> will be created in the user's
171 home directory as well. The <option>-k</option> option is only
172 valid in conjunction with the <option>-m</option> option. The
173 default is to not create the directory and to not copy any
180 <option>-K</option>, <option>--key</option>
181 <replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable>
185 Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK,
186 PASS_MAX_DAYS and others).
189 Example: <option>-K </option><replaceable>PASS_MAX_DAYS</replaceable>=<replaceable>-1</replaceable>
190 can be used when creating system account to turn off password
191 ageing, even though system account has no password at all.
192 Multiple <option>-K</option> options can be specified, e.g.:
194 <replaceable>UID_MIN</replaceable>=<replaceable>100</replaceable>
195 <option> -K </option>
196 <replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
199 Note: <option>-K </option>
200 <replaceable>UID_MIN</replaceable>=<replaceable>10</replaceable>,<replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
207 <option>-o</option>, <option>--non-unique</option>
210 <para>Allow the creation of a user account with a duplicate (non-unique) UID.</para>
215 <option>-p</option>, <option>--password</option>
216 <replaceable>PASSWORD</replaceable>
220 The encrypted password, as returned by <citerefentry>
221 <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
222 </citerefentry>. The default is to disable the account.
228 <option>-s</option>, <option>--shell</option>
229 <replaceable>SHELL</replaceable>
233 The name of the user's login shell. The default is to leave this
234 field blank, which causes the system to select the default login
241 <option>-u</option>, <option>--uid</option>
242 <replaceable>UID</replaceable>
246 The numerical value of the user's ID. This value must be unique,
247 unless the <option>-o</option> option is used. The value must be
248 non-negative. The default is to use the smallest ID value
249 greater than 999 and greater than every other user. Values
250 between 0 and 999 are typically reserved for system accounts.
256 <refsect2 id='changing_the_default_values'>
257 <title>Changing the default values</title>
259 When invoked with the <option>-D</option> option,
260 <command>useradd</command> will either display the current default
261 values, or update the default values from the command line. The
264 <variablelist remap='IP'>
267 <option>-b</option> <replaceable>HOME_DIR</replaceable>
271 The initial path prefix for a new user's home directory. The
272 user's name will be affixed to the end of
273 <replaceable>HOME_DIR</replaceable> to create the new
274 directory name if the <option>-d</option> option is not used
275 when creating a new account.
281 <option>-e</option> <replaceable>EXPIRE_DATE</replaceable>
284 <para>The date on which the user account is disabled.</para>
289 <option>-f</option> <replaceable>INACTIVE</replaceable>
293 The number of days after a password has expired before the
294 account will be disabled.
300 <option>-g</option>, <option>--gid</option>
301 <replaceable>GROUP</replaceable>
305 The group name or ID for a new user's initial group. The named
306 group must exist, and a numerical group ID must have an
313 <option>-s</option>, <option>--shell</option>
314 <replaceable>SHELL</replaceable>
318 The name of the new user's login shell. The named program will
319 be used for all future new user accounts.
326 If no options are specified, <command>useradd</command> displays the
327 current default values.
332 <refsect1 id='notes'>
334 <para>The system administrator is responsible for placing the default
335 user files in the <filename>/etc/skel/</filename> directory.
339 <refsect1 id='caveats'>
340 <title>CAVEATS</title>
342 You may not add a user to a NIS group. This must be performed on the
347 Similarly, if the username already exists in an external user
348 database such as NIS, <command>useradd</command> will deny
349 the user account creation request.
353 Usernames must begin with a lower case letter or an underscore, and
354 only lower case letters, underscores, dashes, and dollar signs may
355 follow. In regular expression terms: [a-z_][a-z0-9_-]*[$]
359 <refsect1 id='files'>
363 <term><filename>/etc/passwd</filename></term>
365 <para>User account information.</para>
369 <term><filename>/etc/shadow</filename></term>
371 <para>Secure user account information.</para>
375 <term><filename>/etc/group</filename></term>
377 <para>Group account information.</para>
381 <term><filename>/etc/default/useradd</filename></term>
383 <para>Default values for account creation.</para>
387 <term><filename>/etc/skel/</filename></term>
389 <para>Directory containing default files.</para>
393 <term><filename>/etc/login.defs</filename></term>
395 <para>Shadow password suite configuration.</para>
401 <refsect1 id='exit_values'>
402 <title>EXIT VALUES</title>
404 The <command>useradd</command> command exits with the following values:
407 <term><replaceable>0</replaceable></term>
413 <term><replaceable>1</replaceable></term>
415 <para>can't update password file</para>
419 <term><replaceable>2</replaceable></term>
421 <para>invalid command syntax</para>
425 <term><replaceable>3</replaceable></term>
427 <para>invalid argument to option</para>
431 <term><replaceable>4</replaceable></term>
433 <para>UID already in use (and no <option>-o</option>)</para>
437 <term><replaceable>6</replaceable></term>
439 <para>specified group doesn't exist</para>
443 <term><replaceable>9</replaceable></term>
445 <para>username already in use</para>
449 <term><replaceable>10</replaceable></term>
451 <para>can't update group file</para>
455 <term><replaceable>12</replaceable></term>
457 <para>can't create home directory</para>
461 <term><replaceable>13</replaceable></term>
463 <para>can't create mail spool</para>
470 <refsect1 id='see_also'>
471 <title>SEE ALSO</title>
474 <refentrytitle>chfn</refentrytitle><manvolnum>1</manvolnum>
477 <refentrytitle>chsh</refentrytitle><manvolnum>1</manvolnum>
480 <refentrytitle>passwd</refentrytitle><manvolnum>1</manvolnum>
483 <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
486 <refentrytitle>groupadd</refentrytitle><manvolnum>8</manvolnum>
489 <refentrytitle>groupdel</refentrytitle><manvolnum>8</manvolnum>
492 <refentrytitle>groupmod</refentrytitle><manvolnum>8</manvolnum>
495 <refentrytitle>login.defs</refentrytitle><manvolnum>5</manvolnum>
498 <refentrytitle>userdel</refentrytitle><manvolnum>8</manvolnum>
501 <refentrytitle>usermod</refentrytitle><manvolnum>8</manvolnum>