]> granicus.if.org Git - shadow/blob - man/useradd.8.xml
[svn-upgrade] Integrating new upstream version, shadow (4.0.16)
[shadow] / man / useradd.8.xml
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 $ -->
4   <refmeta>
5     <refentrytitle>useradd</refentrytitle>
6     <manvolnum>8</manvolnum>
7     <refmiscinfo class="sectdesc">System Management Commands</refmiscinfo>
8   </refmeta>
9   <refnamediv id='name'>
10     <refname>useradd</refname>
11     <refpurpose>create a new user or update default new user information</refpurpose>
12   </refnamediv>
13   <refsynopsisdiv id='synopsis'>
14     <cmdsynopsis>
15       <command>useradd</command>
16       <arg choice='opt'>
17         <replaceable>options</replaceable>
18       </arg>
19       <arg choice='plain'><replaceable>LOGIN</replaceable></arg>
20     </cmdsynopsis>
21     <cmdsynopsis>
22       <command>useradd</command>
23       <arg choice='plain'>-D </arg>
24     </cmdsynopsis>
25     <cmdsynopsis>
26       <command>useradd</command>
27       <arg choice='plain'>-D </arg>
28       <arg choice='opt'>
29         <replaceable>options</replaceable>
30       </arg>
31     </cmdsynopsis>
32   </refsynopsisdiv>
33
34   <refsect1 id='description'>
35     <title>DESCRIPTION</title>
36       <para>
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.
43       </para>
44   </refsect1>
45
46   <refsect1 id='options'>
47     <title>OPTIONS</title>
48     <para>The options which apply to the <command>useradd</command> command are:
49     </para>
50     <variablelist remap='IP'>
51       <varlistentry>
52         <term>
53           <option>-c</option>, <option>--comment</option>
54           <replaceable>COMMENT</replaceable>
55         </term>
56         <listitem>
57           <para>
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
60             name.
61           </para>
62         </listitem>
63       </varlistentry>
64       <varlistentry>
65         <term>
66           <option>-b</option>, <option>--base-dir</option>
67           <replaceable>BASE_DIR</replaceable>
68         </term>
69         <listitem>
70           <para>
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.
76           </para>
77         </listitem>
78       </varlistentry>
79       <varlistentry>
80         <term>
81           <option>-d</option>, <option>--home</option>
82           <replaceable>HOME_DIR</replaceable>
83         </term>
84         <listitem>
85           <para>
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.
93           </para>
94         </listitem>
95       </varlistentry>
96       <varlistentry>
97         <term>
98           <option>-e</option>, <option>--expiredate</option>
99           <replaceable>EXPIRE_DATE</replaceable>
100         </term>
101         <listitem>
102           <para>
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>.
105           </para>
106         </listitem>
107       </varlistentry>
108       <varlistentry>
109         <term>
110           <option>-f</option>, <option>--inactive</option>
111           <replaceable>INACTIVE</replaceable>
112         </term>
113         <listitem>
114           <para>
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.
119           </para>
120         </listitem>
121       </varlistentry>
122       <varlistentry>
123         <term>
124           <option>-g</option>, <option>--gid</option>
125           <replaceable>GROUP</replaceable>
126         </term>
127         <listitem>
128           <para>
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>.
133           </para>
134         </listitem>
135       </varlistentry>
136       <varlistentry>
137         <term>
138           <option>-G</option>, <option>--groups</option>
139           <replaceable>GROUP1</replaceable>[<emphasis remap='I'>,GROUP2,...</emphasis>[<emphasis remap='I'>,GROUPN</emphasis>]]]
140         </term>
141         <listitem>
142           <para>
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
148             initial group.
149           </para>
150         </listitem>
151       </varlistentry>
152       <varlistentry>
153         <term><option>-h</option>, <option>--help</option></term>
154         <listitem>
155           <para>Display help message and exit.</para>
156         </listitem>
157       </varlistentry>
158       <varlistentry>
159         <term>
160           <option>-m</option>, <option>--create-home</option>
161         </term>
162         <listitem>
163           <para>
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
174             files.
175           </para>
176         </listitem>
177       </varlistentry>
178       <varlistentry>
179         <term>
180           <option>-K</option>, <option>--key</option>
181           <replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable>
182         </term>
183         <listitem>
184           <para>
185             Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK,
186             PASS_MAX_DAYS and others).
187           <para>
188           </para>
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.:
193             <option>-K </option>
194             <replaceable>UID_MIN</replaceable>=<replaceable>100</replaceable>
195             <option> -K </option>
196             <replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
197           </para>
198           <para>
199             Note: <option>-K </option>
200             <replaceable>UID_MIN</replaceable>=<replaceable>10</replaceable>,<replaceable>UID_MAX</replaceable>=<replaceable>499</replaceable>
201             doesn't work yet.
202           </para>
203         </listitem>
204       </varlistentry>
205       <varlistentry>
206         <term>
207           <option>-o</option>, <option>--non-unique</option>
208         </term>
209         <listitem>
210           <para>Allow the creation of a user account with a duplicate (non-unique) UID.</para>
211         </listitem>
212       </varlistentry>
213       <varlistentry>
214         <term>
215           <option>-p</option>, <option>--password</option>
216           <replaceable>PASSWORD</replaceable>
217         </term>
218         <listitem>
219           <para>
220             The encrypted password, as returned by <citerefentry>
221             <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
222             </citerefentry>. The default is to disable the account.
223           </para>
224         </listitem>
225       </varlistentry>
226       <varlistentry>
227         <term>
228           <option>-s</option>, <option>--shell</option>
229           <replaceable>SHELL</replaceable>
230         </term>
231         <listitem>
232           <para>
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
235             shell.
236           </para>
237         </listitem>
238       </varlistentry>
239       <varlistentry>
240         <term>
241           <option>-u</option>, <option>--uid</option>
242           <replaceable>UID</replaceable>
243         </term>
244         <listitem>
245           <para>
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.
251           </para>
252         </listitem>
253       </varlistentry>
254     </variablelist>
255
256     <refsect2 id='changing_the_default_values'>
257       <title>Changing the default values</title>
258       <para>
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
262         valid options are
263       </para>
264       <variablelist remap='IP'>
265         <varlistentry>
266           <term>
267             <option>-b</option> <replaceable>HOME_DIR</replaceable>
268           </term>
269           <listitem>
270             <para>
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.
276             </para>
277           </listitem>
278         </varlistentry>
279         <varlistentry>
280           <term>
281             <option>-e</option> <replaceable>EXPIRE_DATE</replaceable>
282           </term>
283           <listitem>
284             <para>The date on which the user account is disabled.</para>
285           </listitem>
286         </varlistentry>
287         <varlistentry>
288           <term>
289             <option>-f</option> <replaceable>INACTIVE</replaceable>
290           </term>
291           <listitem>
292             <para>
293               The number of days after a password has expired before the
294               account will be disabled.
295             </para>
296           </listitem>
297         </varlistentry>
298         <varlistentry>
299           <term>
300             <option>-g</option>, <option>--gid</option>
301             <replaceable>GROUP</replaceable>
302           </term>
303           <listitem>
304             <para>
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
307               existing entry.
308             </para>
309           </listitem>
310         </varlistentry>
311         <varlistentry>
312           <term>
313             <option>-s</option>, <option>--shell</option>
314             <replaceable>SHELL</replaceable>
315           </term>
316           <listitem>
317             <para>
318               The name of the new user's login shell. The named program will
319               be used for all future new user accounts.
320             </para>
321           </listitem>
322         </varlistentry>
323       </variablelist>
324
325       <para>
326         If no options are specified, <command>useradd</command> displays the
327         current default values.
328       </para>
329     </refsect2>
330   </refsect1>
331
332   <refsect1 id='notes'>
333     <title>NOTES</title>
334     <para>The system administrator is responsible for placing the default
335       user files in the <filename>/etc/skel/</filename> directory.
336     </para>
337   </refsect1>
338
339   <refsect1 id='caveats'>
340     <title>CAVEATS</title>
341     <para>
342       You may not add a user to a NIS group. This must be performed on the
343       NIS server.
344     </para>
345
346     <para>
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.
350     </para>
351
352     <para>
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_-]*[$]
356     </para>
357   </refsect1>
358
359   <refsect1 id='files'>
360     <title>FILES</title>
361     <variablelist>
362       <varlistentry>
363         <term><filename>/etc/passwd</filename></term>
364         <listitem>
365           <para>User account information.</para>
366         </listitem>
367       </varlistentry>
368       <varlistentry>
369         <term><filename>/etc/shadow</filename></term>
370         <listitem>
371           <para>Secure user account information.</para>
372         </listitem>
373       </varlistentry>
374       <varlistentry>
375         <term><filename>/etc/group</filename></term>
376         <listitem>
377           <para>Group account information.</para>
378         </listitem>
379       </varlistentry>
380       <varlistentry>
381         <term><filename>/etc/default/useradd</filename></term>
382         <listitem>
383           <para>Default values for account creation.</para>
384         </listitem>
385       </varlistentry>
386       <varlistentry>
387         <term><filename>/etc/skel/</filename></term>
388         <listitem>
389           <para>Directory containing default files.</para>
390         </listitem>
391       </varlistentry>
392       <varlistentry>
393         <term><filename>/etc/login.defs</filename></term>
394         <listitem>
395           <para>Shadow password suite configuration.</para>
396         </listitem>
397       </varlistentry>
398     </variablelist>
399   </refsect1>
400
401   <refsect1 id='exit_values'>
402     <title>EXIT VALUES</title>
403     <para>
404       The <command>useradd</command> command exits with the following values:
405       <variablelist>
406         <varlistentry>
407           <term><replaceable>0</replaceable></term>
408           <listitem>
409             <para>success</para>
410           </listitem>
411         </varlistentry>
412         <varlistentry>
413           <term><replaceable>1</replaceable></term>
414           <listitem>
415             <para>can't update password file</para>
416           </listitem>
417         </varlistentry>
418         <varlistentry>
419           <term><replaceable>2</replaceable></term>
420           <listitem>
421             <para>invalid command syntax</para>
422           </listitem>
423         </varlistentry>
424         <varlistentry>
425           <term><replaceable>3</replaceable></term>
426           <listitem>
427             <para>invalid argument to option</para>
428           </listitem>
429         </varlistentry>
430         <varlistentry>
431           <term><replaceable>4</replaceable></term>
432           <listitem>
433             <para>UID already in use (and no <option>-o</option>)</para>
434           </listitem>
435         </varlistentry>
436         <varlistentry>
437           <term><replaceable>6</replaceable></term>
438           <listitem>
439             <para>specified group doesn't exist</para>
440           </listitem>
441         </varlistentry>
442         <varlistentry>
443           <term><replaceable>9</replaceable></term>
444           <listitem>
445             <para>username already in use</para>
446           </listitem>
447         </varlistentry>
448         <varlistentry>
449           <term><replaceable>10</replaceable></term>
450           <listitem>
451             <para>can't update group file</para>
452           </listitem>
453         </varlistentry>
454         <varlistentry>
455           <term><replaceable>12</replaceable></term>
456           <listitem>
457             <para>can't create home directory</para>
458           </listitem>
459         </varlistentry>
460         <varlistentry>
461           <term><replaceable>13</replaceable></term>
462           <listitem>
463             <para>can't create mail spool</para>
464           </listitem>
465         </varlistentry>
466       </variablelist>
467     </para>
468   </refsect1>
469
470   <refsect1 id='see_also'>
471     <title>SEE ALSO</title>
472     <para>
473       <citerefentry>
474         <refentrytitle>chfn</refentrytitle><manvolnum>1</manvolnum>
475       </citerefentry>,
476       <citerefentry>
477         <refentrytitle>chsh</refentrytitle><manvolnum>1</manvolnum>
478       </citerefentry>,
479       <citerefentry>
480         <refentrytitle>passwd</refentrytitle><manvolnum>1</manvolnum>
481       </citerefentry>,
482       <citerefentry>
483         <refentrytitle>crypt</refentrytitle><manvolnum>3</manvolnum>
484       </citerefentry>,
485       <citerefentry>
486         <refentrytitle>groupadd</refentrytitle><manvolnum>8</manvolnum>
487       </citerefentry>,
488       <citerefentry>
489         <refentrytitle>groupdel</refentrytitle><manvolnum>8</manvolnum>
490       </citerefentry>,
491       <citerefentry>
492         <refentrytitle>groupmod</refentrytitle><manvolnum>8</manvolnum>
493       </citerefentry>,
494       <citerefentry>
495         <refentrytitle>login.defs</refentrytitle><manvolnum>5</manvolnum>
496       </citerefentry>,
497       <citerefentry>
498         <refentrytitle>userdel</refentrytitle><manvolnum>8</manvolnum>
499       </citerefentry>,
500       <citerefentry>
501         <refentrytitle>usermod</refentrytitle><manvolnum>8</manvolnum>
502       </citerefentry>.
503     </para>
504   </refsect1>
505 </refentry>