xref: /freebsd/usr.sbin/adduser/adduser.8 (revision 729362425c09cf6b362366aabc6fb547eee8035a)
1.\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
2.\" All rights reserved.
3.\" Copyright (c) 2002 Michael Telahun Makonnen <makonnen@pacbell.net>
4.\" 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.\"
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
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd August 14, 2002
30.Dt ADDUSER 8
31.Os
32.Sh NAME
33.Nm adduser
34.Nd command for adding new users
35.Sh SYNOPSIS
36.Nm
37.Op Fl CENhq
38.Op Fl G Ar groups
39.Op Fl L Ar login_class
40.Op Fl d Ar partition
41.Op Fl f Ar file
42.Op Fl g Ar login_group
43.Op Fl k Ar dotdir
44.Op Fl m Ar message_file
45.Op Fl s Ar shell
46.Op Fl u Ar uid_start
47.Op Fl w Ar type
48.Sh DESCRIPTION
49The
50.Nm
51utility is a shell script, implemented around the
52.Xr pw 8
53command, for adding new users.
54It creates passwd/group entries, a home directory,
55copies dotfiles and sends the new user a welcome message.
56It supports two modes of operation.
57It may be used interactively
58at the command line to add one user at a time, or it may be directed
59to get the list of new users from a file and operate in batch mode
60without requiring any user interaction.
61.Sh RESTRICTIONS
62.Bl -tag -width indent
63.It username
64Login name.
65The user name is restricted to whatever
66.Xr pw 8
67will accept.
68Generally this means it
69may contain only lowercase characters or digits.
70Maximum length
71is 16 characters.
72The reasons for this limit are historical.
73Given that people have traditionally wanted to break this
74limit for aesthetic reasons, it has never been of great importance to break
75such a basic fundamental parameter in
76.Ux .
77You can change
78.Dv UT_NAMESIZE
79in
80.Pa /usr/include/utmp.h
81and recompile the
82world; people have done this and it works, but you will have problems
83with any precompiled programs, or source that assumes the 8-character
84name limit and NIS.
85The NIS protocol mandates an 8-character username.
86If you need a longer login name for e-mail addresses,
87you can define an alias in
88.Pa /etc/mail/aliases .
89.It "full name"
90This is typically known as the gecos field and usually contains
91the user's full name.
92Additionally, it may contain a comma separated
93list of values such as office number and work and home phones.
94If the
95name contains an ampersand it will be replaced by the capitalized
96login name when displayed by other programs.
97The
98.Ql \&:
99character is not allowed.
100.It shell
101Only valid shells from the shell database
102.Pq Pa /etc/shells
103are allowed.
104In
105addition, only the base name of the shell is necessary, not the full path.
106.It UID
107Automatically generated or your choice.
108It must be less than 32000.
109.It "GID/login group"
110Automatically generated or your choice.
111It must be less than 32000.
112.It password
113You may choose an empty password, disable the password, use a
114randomly generated password or specify your own plaintext password,
115which will be encrypted before being stored in the user database.
116.El
117.Sh UNIQUE GROUPS
118Perhaps you are missing what
119.Em can
120be done with this scheme that falls apart
121with most other schemes.
122With each user in their own group,
123they can safely run with a umask of 002 instead of the usual 022
124and create files in their home directory
125without worrying about others being able to change them.
126.Pp
127For a shared area you create a separate UID/GID (like cvs or ncvs on freefall),
128you place each person that should be able to access this area into that new
129group.
130.Pp
131This model of UID/GID administration allows far greater flexibility than lumping
132users into groups and having to muck with the umask when working in a shared
133area.
134.Pp
135I have been using this model for almost 10 years and found that it works
136for most situations, and has never gotten in the way.
137(Rod Grimes)
138.Sh CONFIGURATION
139The
140.Nm
141utility reads its configuration information from
142.Pa /etc/adduser.conf .
143If this file does not exist, it will use predefined defaults.
144While this file may be edited by hand,
145the safer option is to use the
146.Fl C
147command line argument.
148With this argument,
149.Nm
150will start interactive input, save the answers to its prompts in
151.Pa /etc/adduser.conf ,
152and promptly exit without modifying the user
153database.
154Options specified on the command line will take precedence over
155any values saved in this file.
156.Sh OPTIONS
157.Bl -tag -width indent
158.It Fl C
159Create new configuration file and exit.
160This option is mutually exclusive with the
161.Fl f
162option.
163.It Fl d Ar partition
164Home partition.
165Default partition, under which all user directories
166will be located.
167.It Fl E
168Disable the account.
169This option will lock the account by prepending the string
170.Dq Li *LOCKED*
171to the password field.
172The account may be unlocked
173by the super-user with the
174.Xr pw 8
175command:
176.Pp
177.D1 Nm pw Cm unlock Op Ar name | uid
178.It Fl f Ar file
179Get the list of accounts to create from
180.Ar file .
181If
182.Ar file
183is
184.Dq Fl ,
185then get the list from standard input.
186If this option is specified,
187.Nm
188will operate in batch mode and will not seek any user input.
189If an error is encountered while processing an account, it will write a
190message to standard error and move to the next account.
191The format
192of the input file is described below.
193.It Fl g Ar login_group
194Normaly,
195if no login group is specified,
196it is assumed to be the same as the username.
197This option makes
198.Ar login_group
199the default.
200.It Fl G Ar groups
201Additional groups.
202This option allows the user to specify additional groups to add users to.
203The user is a member of these groups in addition to their login group.
204.It Fl h
205Print a summary of options and exit.
206.It Fl k Ar directory
207Copy files from
208.Ar directory
209into the home
210directory of new users;
211.Pa dot.foo
212will be renamed to
213.Pa .foo .
214.It Fl L Ar login_class
215Set default login class.
216.It Fl m Ar file
217Send new users a welcome message from
218.Ar file .
219Specifying a value of
220.Cm no
221for
222.Ar file
223causes no message to be sent to new users.
224Please note that the message
225file can reference the internal variables of the
226.Nm
227script.
228.It Fl N
229Do not read the default configuration file.
230.It Fl q
231Minimal user feedback.
232In particular, the random password will not be echoed to
233standard output.
234.It Fl s Ar shell
235Default shell for new users.
236The
237.Ar shell
238argument must be the base name of the shell,
239.Em not
240the full path.
241It must exist in
242.Pa /etc/shells
243to be considered a valid shell.
244.It Fl u Ar uid
245Use UIDs from
246.Ar uid
247on up.
248.It Fl w Ar type
249Password type.
250The
251.Nm
252utility allows the user to specify what type of password to create.
253The
254.Ar type
255argument may have one of the following values:
256.Bl -tag -width ".Cm random"
257.It Cm no
258Disable the password.
259Instead of an encrypted string, the password field will contain a single
260.Ql *
261character.
262The user may not log in until the super-user
263manually enables the password.
264.It Cm none
265Use an empty string as the password.
266.It Cm yes
267Use a user-supplied string as the password.
268In interactive mode,
269the user will be prompted for the password.
270In batch mode, the
271last (10th) field in the line is assumed to be the password.
272.It Cm random
273Generate a random string and use it as a password.
274The password will be echoed to standard output.
275In addition, it will be available for inclusion in the message file in the
276.Va randompass
277variable.
278.El
279.El
280.Sh FORMAT
281When the
282.Fl f
283option is used, the account information must be stored in a specific
284format.
285All empty lines or lines beginning with a
286.Ql #
287will be ignored.
288All other lines must contain ten colon
289.Pq Ql \&:
290separated fields as described below.
291Command line options do not take precedence
292over values in the fields.
293Only the password field may contain a
294.Ql \&:
295character as part of the string.
296.Pp
297.Sm off
298.D1 Ar name : uid : gid : class : change : expire : gecos : home_dir : shell : password
299.Sm on
300.Bl -tag -width ".Ar password"
301.It Ar name
302Login name.
303This field may not be empty.
304.It Ar uid
305Numeric login user ID.
306If this field is left empty, it will be automatically generated.
307.It Ar gid
308Numeric primary group ID.
309If this field is left empty, a group with the
310same name as the user name will be created and its GID will be used
311instead.
312.It Ar class
313Login class.
314This field may be left empty.
315.It Ar change
316Password ageing.
317This field denotes the password change date for the account.
318The format of this field is the same as the format of the
319.Fl p
320argument to
321.Xr pw 8 .
322It may be
323.Ar dd Ns - Ns Ar mmm Ns - Ns Ar yy Ns Op Ar yy ,
324where
325.Ar dd
326is for the day,
327.Ar mmm
328is for the month in numeric or alphabetical format:
329.Dq Li 10
330or
331.Dq Li Oct ,
332and
333.Ar yy Ns Op Ar yy
334is the four or two digit year.
335To denote a time relative to the current date the format is:
336.No + Ns Ar n Ns Op Ar mhdwoy ,
337where
338.Ar n
339denotes a number, followed by the minutes, hours, days, weeks,
340months or years after which the password must be changed.
341This field may be left empty to turn it off.
342.It Ar expire
343Account expiration.
344This field denotes the expiry date of the account.
345The account may not be used after the specified date.
346The format of this field is the same as that for password ageing.
347This field may be left empty to turn it off.
348.It Ar gecos
349Full name and other extra information about the user.
350.It Ar home_dir
351Home directory.
352If this field is left empty, it will be automatically
353created by appending the username to the home partition.
354.It Ar shell
355Login shell.
356This field should contain the full path to a valid login shell.
357.It Ar password
358User password.
359This field should contain a plaintext string, which will
360be encrypted before being placed in the user database.
361If the password type is
362.Cm yes
363and this field is empty, it is assumed the account will have an empty password.
364If the password type is
365.Cm random
366and this field is
367.Em not
368empty, its contents will be used
369as a password.
370This field will be ignored if the
371.Fl p
372option is used with a
373.Cm no
374or
375.Cm none
376argument.
377Be careful not to terminate this field with a closing
378.Ql \&:
379because it will be treated as part of the password.
380.El
381.Sh FILES
382.Bl -tag -width ".Pa /etc/adduser.message" -compact
383.It Pa /etc/master.passwd
384user database
385.It Pa /etc/group
386group database
387.It Pa /etc/shells
388shell database
389.It Pa /etc/login.conf
390login classes database
391.It Pa /etc/adduser.conf
392configuration file for
393.Nm
394.It Pa /etc/adduser.message
395message file for
396.Nm
397.It Pa /usr/share/skel
398skeletal login directory
399.It Pa /var/log/adduser
400logfile for
401.Nm
402.El
403.Sh SEE ALSO
404.Xr chpass 1 ,
405.Xr passwd 1 ,
406.Xr aliases 5 ,
407.Xr group 5 ,
408.Xr login.conf 5 ,
409.Xr passwd 5 ,
410.Xr shells 5 ,
411.Xr pw 8 ,
412.Xr pwd_mkdb 8 ,
413.Xr rmuser 8 ,
414.Xr vipw 8 ,
415.Xr yp 8
416.Sh HISTORY
417The
418.Nm
419command appeared in
420.Fx 2.1 .
421.Sh AUTHORS
422.An -nosplit
423This manual page and the original script, in Perl, was written by
424.An Wolfram Schneider Aq wosch@FreeBSD.org .
425The replacement script, written as a Bourne
426shell script with some enhancements, and the man page modification that
427came with it were done by
428.An Mike Makonnen Aq mtm@identd.net .
429.Sh BUGS
430In order for
431.Nm
432to correctly expand variables such as
433.Va $username
434and
435.Va $randompass
436in the message sent to new users, it must let the shell evaluate
437each line of the message file.
438This means that shell commands can also be embedded in the message file.
439The
440.Nm
441utility attempts to mitigate the possibility of an attacker using this
442feature by refusing to evaluate the file if it is not owned and writeable
443only by the root user.
444In addition, shell special characters and operators will have to be
445escaped when used in the message file.
446.Pp
447Also, password ageing and account expiry times are currently setable
448only in batch mode.
449The user should be able to set them in interactive mode as well.
450