1 <?xml version="1.0" encoding="UTF-8"?>
3 Copyright (c) 1991 - 1994, Julianne Frances Haugh
4 Copyright (c) 2007 - 2009, Nicolas François
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 3. The name of the copyright holders or contributors may not be used to
16 endorse or promote products derived from this software without
17 specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
32 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
33 <!ENTITY CREATE_HOME SYSTEM "login.defs.d/CREATE_HOME.xml">
34 <!ENTITY GID_MAX SYSTEM "login.defs.d/GID_MAX.xml">
35 <!ENTITY MAIL_DIR SYSTEM "login.defs.d/MAIL_DIR.xml">
36 <!ENTITY MAX_MEMBERS_PER_GROUP SYSTEM "login.defs.d/MAX_MEMBERS_PER_GROUP.xml">
37 <!ENTITY PASS_MAX_DAYS SYSTEM "login.defs.d/PASS_MAX_DAYS.xml">
38 <!ENTITY PASS_MIN_DAYS SYSTEM "login.defs.d/PASS_MIN_DAYS.xml">
39 <!ENTITY PASS_WARN_AGE SYSTEM "login.defs.d/PASS_WARN_AGE.xml">
40 <!ENTITY SYS_GID_MAX SYSTEM "login.defs.d/SYS_GID_MAX.xml">
41 <!ENTITY SYS_UID_MAX SYSTEM "login.defs.d/SYS_UID_MAX.xml">
42 <!ENTITY UID_MAX SYSTEM "login.defs.d/UID_MAX.xml">
43 <!ENTITY UMASK SYSTEM "login.defs.d/UMASK.xml">
44 <!ENTITY TCB_AUTH_GROUP SYSTEM "login.defs.d/TCB_AUTH_GROUP.xml">
45 <!ENTITY TCB_SYMLINKS SYSTEM "login.defs.d/TCB_SYMLINKS.xml">
46 <!ENTITY USE_TCB SYSTEM "login.defs.d/USE_TCB.xml">
47 <!ENTITY USERGROUPS_ENAB SYSTEM "login.defs.d/USERGROUPS_ENAB.xml">
49 <refentry id='useradd.8'>
52 <refentrytitle>useradd</refentrytitle>
53 <manvolnum>8</manvolnum>
54 <refmiscinfo class="sectdesc">System Management Commands</refmiscinfo>
56 <refnamediv id='name'>
57 <refname>useradd</refname>
58 <refpurpose>create a new user or update default new user information</refpurpose>
60 <refsynopsisdiv id='synopsis'>
62 <command>useradd</command>
64 <replaceable>options</replaceable>
66 <arg choice='plain'><replaceable>LOGIN</replaceable></arg>
69 <command>useradd</command>
70 <arg choice='plain'>-D </arg>
73 <command>useradd</command>
74 <arg choice='plain'>-D </arg>
76 <replaceable>options</replaceable>
81 <refsect1 id='description'>
82 <title>DESCRIPTION</title>
84 When invoked without the <option>-D</option> option, the
85 <command>useradd</command> command creates a new user account using
86 the values specified on the command line plus the default values from
87 the system. Depending on command line options, the
88 <command>useradd</command> command
89 will update system files and may also create the new user's home
90 directory and copy initial files.
93 By default, a group will also be created for the new user (see
94 <option>-g</option>, <option>-N</option>, <option>-U</option>, and
95 <option>USERGROUPS_ENAB</option>).
99 <refsect1 id='options'>
100 <title>OPTIONS</title>
101 <para>The options which apply to the <command>useradd</command> command are:
103 <variablelist remap='IP'>
106 <option>-b</option>, <option>--base-dir</option>
107 <replaceable>BASE_DIR</replaceable>
111 The default base directory for the system if <option>-d</option>
112 <replaceable>HOME_DIR</replaceable> is not specified.
113 <replaceable>BASE_DIR</replaceable> is
114 concatenated with the account name to define the home directory.
115 If the <option>-m</option> option is not used,
116 <replaceable>BASE_DIR</replaceable> must exist.
119 If this option is not specified, <command>useradd</command>
120 will use the base directory specified by the
121 <option>HOME</option> variable in
122 <filename>/etc/default/useradd</filename>, or
123 <filename>/home</filename> by default.
129 <option>-c</option>, <option>--comment</option>
130 <replaceable>COMMENT</replaceable>
134 Any text string. It is generally a short description of the
135 login, and is currently used as the field for the user's full
142 <option>-d</option>, <option>--home</option>
143 <replaceable>HOME_DIR</replaceable>
147 The new user will be created using
148 <replaceable>HOME_DIR</replaceable> as the value for the user's
149 login directory. The default is to append the
150 <replaceable>LOGIN</replaceable> name to
151 <replaceable>BASE_DIR</replaceable> and use that as the login
152 directory name. The directory <replaceable>HOME_DIR</replaceable>
153 does not have to exist but will not be created if it is missing.
159 <option>-D</option>, <option>--defaults</option>
163 See below, the subsection "Changing the default values".
169 <option>-e</option>, <option>--expiredate</option>
170 <replaceable>EXPIRE_DATE</replaceable>
174 The date on which the user account will be disabled. The date is
175 specified in the format <emphasis remap='I'>YYYY-MM-DD</emphasis>.
178 If not specified, <command>useradd</command> will use the
179 default expiry date specified by the <option>EXPIRE</option>
180 variable in <filename>/etc/default/useradd</filename>, or
181 an empty string (no expiry) by default.
187 <option>-f</option>, <option>--inactive</option>
188 <replaceable>INACTIVE</replaceable>
192 The number of days after a password expires until the account is
193 permanently disabled. A value of 0 disables the account as soon
194 as the password has expired, and a value of -1 disables the
198 If not specified, <command>useradd</command> will use the
199 default inactivity period specified by the
200 <option>INACTIVE</option> variable in
201 <filename>/etc/default/useradd</filename>, or -1 by default.
207 <option>-g</option>, <option>--gid</option>
208 <replaceable>GROUP</replaceable>
212 The group name or number of the user's initial login group. The
213 group name must exist. A group number must refer to an already
217 If not specified, the behavior of <command>useradd</command>
218 will depend on the <option>USERGROUPS_ENAB</option> variable
219 in <filename>/etc/login.defs</filename>. If this variable is
220 set to <replaceable>yes</replaceable> (or
221 <option>-U/--user-group</option> is specified on the command
222 line), a group will be created for the user, with the same
223 name as her loginname. If the variable is set to
224 <replaceable>no</replaceable> (or
225 <option>-N/--no-user-group</option> is specified on the
226 command line), useradd will set the primary group of the new
227 user to the value specified by the <option>GROUP</option>
228 variable in <filename>/etc/default/useradd</filename>, or
235 <option>-G</option>, <option>--groups</option>
236 <replaceable>GROUP1</replaceable>[<emphasis remap='I'>,GROUP2,...</emphasis>[<emphasis remap='I'>,GROUPN</emphasis>]]]
240 A list of supplementary groups which the user is also a member
241 of. Each group is separated from the next by a comma, with no
242 intervening whitespace. The groups are subject to the same
243 restrictions as the group given with the <option>-g</option>
244 option. The default is for the user to belong only to the
250 <term><option>-h</option>, <option>--help</option></term>
252 <para>Display help message and exit.</para>
257 <option>-k</option>, <option>--skel</option>
258 <replaceable>SKEL_DIR</replaceable>
262 The skeleton directory, which contains files and directories
263 to be copied in the user's home directory, when the home
264 directory is created by <command>useradd</command>.
267 This option is only valid if the <option>-m</option> (or
268 <option>--create-home</option>) option is specified.
271 If this option is not set, the skeleton directory is defined
272 by the <option>SKEL</option> variable in
273 <filename>/etc/default/useradd</filename> or, by default,
274 <filename>/etc/skel</filename>.
277 If possible, the ACLs and extended attributes are copied.
283 <option>-K</option>, <option>--key</option>
284 <replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable>
288 Overrides <filename>/etc/login.defs</filename> defaults
289 (<option>UID_MIN</option>, <option>UID_MAX</option>,
290 <option>UMASK</option>, <option>PASS_MAX_DAYS</option>
294 Example: <option>-K </option><replaceable>PASS_MAX_DAYS</replaceable>=<replaceable>-1</replaceable>
295 can be used when creating system account to turn off password
296 ageing, even though system account has no password at all.
297 Multiple <option>-K</option> options can be specified, e.g.:
299 <replaceable>UID_MIN</replaceable>=<replaceable>100</replaceable>
301 <replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
304 Note: <option>-K </option>
305 <replaceable>UID_MIN</replaceable>=<replaceable>10</replaceable>,<replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
311 <term><option>-l</option>, <option>--no-log-init</option></term>
314 Do not add the user to the lastlog and faillog databases.
317 By default, the user's entries in the lastlog and faillog
318 databases are resetted to avoid reusing the entry from a previously
325 <option>-m</option>, <option>--create-home</option>
329 Create the user's home directory if it does not exist.
330 The files and directories contained in the skeleton directory
331 (which can be defined with the <option>-k</option> option)
332 will be copied to the home directory.
335 By default, if this option is not specified and
336 <option>CREATE_HOME</option> is not enabled, no home
337 directories are created.
347 Do no create the user's home directory, even if the system
348 wide setting from <filename>/etc/login.defs</filename>
349 (<option>CREATE_HOME</option>) is set to
350 <replaceable>yes</replaceable>.
356 <option>-N</option>, <option>--no-user-group</option>
360 Do not create a group with the same name as the user, but
361 add the user to the group specified by the <option>-g</option>
362 option or by the <option>GROUP</option> variable in
363 <filename>/etc/default/useradd</filename>.
366 The default behavior (if the <option>-g</option>,
367 <option>-N</option>, and <option>-U</option> options are not
368 specified) is defined by the <option>USERGROUPS_ENAB</option>
369 variable in <filename>/etc/login.defs</filename>.
375 <option>-o</option>, <option>--non-unique</option>
378 <para>Allow the creation of a user account with a duplicate (non-unique) UID.</para>
380 This option is only valid in combination with the
381 <option>-u</option> option.
387 <option>-p</option>, <option>--password</option>
388 <replaceable>PASSWORD</replaceable>
392 The encrypted password, as returned by <citerefentry>
393 <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
394 </citerefentry>. The default is to disable the password.
397 <emphasis role="bold">Note:</emphasis> This option is not
398 recommended because the password (or encrypted password) will
399 be visible by users listing the processes.
402 You should make sure the password respects the system's
409 <option>-r</option>, <option>--system</option>
413 Create a system account.
416 System users will be created with no aging information in
417 <filename>/etc/shadow</filename>, and their numeric
418 identifiers are chosen in the
419 <option>SYS_UID_MIN</option>-<option>SYS_UID_MAX</option>
420 range, defined in <filename>/etc/login.defs</filename>, instead of
421 <option>UID_MIN</option>-<option>UID_MAX</option> (and their
422 <option>GID</option> counterparts for the creation of groups).
425 Note that <command>useradd</command> will not create a home
426 directory for such an user, regardless of the default setting
427 in <filename>/etc/login.defs</filename>
428 (<option>CREATE_HOME</option>). You have to specify the
429 <option>-m</option> options if you want a home directory for a
430 system account to be created.
436 <option>-s</option>, <option>--shell</option>
437 <replaceable>SHELL</replaceable>
441 The name of the user's login shell. The default is to leave this
442 field blank, which causes the system to select the default login
443 shell specified by the <option>SHELL</option> variable in
444 <filename>/etc/default/useradd</filename>, or an empty string
451 <option>-u</option>, <option>--uid</option>
452 <replaceable>UID</replaceable>
456 The numerical value of the user's ID. This value must be unique,
457 unless the <option>-o</option> option is used. The value must be
458 non-negative. The default is to use the smallest ID value
459 greater than 999 and greater than every other user. Values
460 between 0 and 999 are typically reserved for system accounts.
466 <option>-U</option>, <option>--user-group</option>
470 Create a group with the same name as the user, and
471 add the user to this group.
474 The default behavior (if the <option>-g</option>,
475 <option>-N</option>, and <option>-U</option> options are not
476 specified) is defined by the <option>USERGROUPS_ENAB</option>
477 variable in <filename>/etc/login.defs</filename>.
483 <option>-Z</option>, <option>--selinux-user</option>
484 <replaceable>SEUSER</replaceable>
488 The SELinux user for the user's login. The default is to leave this
489 field blank, which causes the system to select the default SELinux
496 <refsect2 id='changing_the_default_values'>
497 <title>Changing the default values</title>
499 When invoked with only the <option>-D</option> option,
500 <command>useradd</command> will display the current default values.
501 When invoked with <option>-D</option> plus other options,
502 <command>useradd</command> will update the default values for the
503 specified options. Valid default-changing options are:
505 <variablelist remap='IP'>
508 <option>-b</option>, <option>--base-dir</option>
509 <replaceable>BASE_DIR</replaceable>
513 The path prefix for a new user's home directory. The
514 user's name will be affixed to the end of
515 <replaceable>BASE_DIR</replaceable> to form the new user's
516 home directory name, if the <option>-d</option> option is not used
517 when creating a new account.
520 This option sets the <option>HOME</option> variable in
521 <filename>/etc/default/useradd</filename>.
527 <option>-e</option>, <option>--expiredate</option>
528 <replaceable>EXPIRE_DATE</replaceable>
531 <para>The date on which the user account is disabled.</para>
533 This option sets the <option>EXPIRE</option> variable in
534 <filename>/etc/default/useradd</filename>.
540 <option>-f</option>, <option>--inactive</option>
541 <replaceable>INACTIVE</replaceable>
545 The number of days after a password has expired before the
546 account will be disabled.
549 This option sets the <option>INACTIVE</option> variable in
550 <filename>/etc/default/useradd</filename>.
556 <option>-g</option>, <option>--gid</option>
557 <replaceable>GROUP</replaceable>
561 The group name or ID for a new user's initial group (when
562 the <option>-N/--no-user-group</option> is used or when the
563 <option>USERGROUPS_ENAB</option> variable is set to
564 <replaceable>no</replaceable> in
565 <filename>/etc/login.defs</filename>. The named
566 group must exist, and a numerical group ID must have an
570 This option sets the <option>GROUP</option> variable in
571 <filename>/etc/default/useradd</filename>.
577 <option>-s</option>, <option>--shell</option>
578 <replaceable>SHELL</replaceable>
582 The name of a new user's login shell.
585 This option sets the <option>SHELL</option> variable in
586 <filename>/etc/default/useradd</filename>.
595 <refsect1 id='notes'>
597 <para>The system administrator is responsible for placing the default
598 user files in the <filename>/etc/skel/</filename> directory (or any
599 other skeleton directory specified in
600 <filename>/etc/default/useradd</filename> or on the command line).
604 <refsect1 id='caveats'>
605 <title>CAVEATS</title>
607 You may not add a user to a NIS or LDAP group. This must be
608 performed on the corresponding server.
612 Similarly, if the username already exists in an external user
613 database such as NIS or LDAP, <command>useradd</command> will deny
614 the user account creation request.
618 Usernames must start with a lower case letter or an underscore,
619 followed by lower case letters, digits, underscores, or dashes.
620 They can end with a dollar sign.
621 In regular expression terms: [a-z_][a-z0-9_-]*[$]?
624 Usernames may only be up to 32 characters long.
628 <refsect1 id='configuration'>
629 <title>CONFIGURATION</title>
631 The following configuration variables in
632 <filename>/etc/login.defs</filename> change the behavior of this
637 &GID_MAX; <!-- documents also GID_MIN -->
639 &MAX_MEMBERS_PER_GROUP;
643 &SYS_GID_MAX; <!-- documents also SYS_GID_MIN -->
644 &SYS_UID_MAX; <!-- documents also SYS_UID_MIN -->
647 &UID_MAX; <!-- documents also UID_MIN -->
654 <refsect1 id='files'>
658 <term><filename>/etc/passwd</filename></term>
660 <para>User account information.</para>
664 <term><filename>/etc/shadow</filename></term>
666 <para>Secure user account information.</para>
670 <term><filename>/etc/group</filename></term>
672 <para>Group account information.</para>
675 <varlistentry condition="gshadow">
676 <term><filename>/etc/gshadow</filename></term>
678 <para>Secure group account information.</para>
682 <term><filename>/etc/default/useradd</filename></term>
684 <para>Default values for account creation.</para>
688 <term><filename>/etc/skel/</filename></term>
690 <para>Directory containing default files.</para>
694 <term><filename>/etc/login.defs</filename></term>
696 <para>Shadow password suite configuration.</para>
702 <refsect1 id='exit_values'>
703 <title>EXIT VALUES</title>
705 The <command>useradd</command> command exits with the following values:
708 <term><replaceable>0</replaceable></term>
714 <term><replaceable>1</replaceable></term>
716 <para>can't update password file</para>
720 <term><replaceable>2</replaceable></term>
722 <para>invalid command syntax</para>
726 <term><replaceable>3</replaceable></term>
728 <para>invalid argument to option</para>
732 <term><replaceable>4</replaceable></term>
734 <para>UID already in use (and no <option>-o</option>)</para>
738 <term><replaceable>6</replaceable></term>
740 <para>specified group doesn't exist</para>
744 <term><replaceable>9</replaceable></term>
746 <para>username already in use</para>
750 <term><replaceable>10</replaceable></term>
752 <para>can't update group file</para>
756 <term><replaceable>12</replaceable></term>
758 <para>can't create home directory</para>
762 <term><replaceable>13</replaceable></term>
764 <para>can't create mail spool</para>
771 <refsect1 id='see_also'>
772 <title>SEE ALSO</title>
775 <refentrytitle>chfn</refentrytitle><manvolnum>1</manvolnum>
778 <refentrytitle>chsh</refentrytitle><manvolnum>1</manvolnum>
781 <refentrytitle>passwd</refentrytitle><manvolnum>1</manvolnum>
784 <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
787 <refentrytitle>groupadd</refentrytitle><manvolnum>8</manvolnum>
790 <refentrytitle>groupdel</refentrytitle><manvolnum>8</manvolnum>
793 <refentrytitle>groupmod</refentrytitle><manvolnum>8</manvolnum>
796 <refentrytitle>login.defs</refentrytitle><manvolnum>5</manvolnum>
799 <refentrytitle>newusers</refentrytitle><manvolnum>8</manvolnum>
802 <refentrytitle>userdel</refentrytitle><manvolnum>8</manvolnum>
805 <refentrytitle>usermod</refentrytitle><manvolnum>8</manvolnum>