xref: /openbsd-src/usr.sbin/adduser/adduser.8 (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1.\"	$OpenBSD: adduser.8,v 1.42 2013/01/18 21:48:43 jmc Exp $
2.\"
3.\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
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.\" $From: adduser.8,v 1.12 1996/08/28 17:54:13 adam Exp $
28.Dd $Mdocdate: January 18 2013 $
29.Dt ADDUSER 8
30.Os
31.Sh NAME
32.Nm adduser ,
33.Nm rmuser
34.Nd add and delete users from the system
35.Sh SYNOPSIS
36.Nm adduser
37.Bk -words
38.Oo Fl batch Ar username
39.Oo Ar group Ns Op , Ns Ar group
40.Ar ...
41.Oc
42.Op Ar fullname
43.Op Ar password
44.Oc
45.Op Fl check_only
46.Op Fl class Ar login_class
47.Op Fl config_create
48.Op Fl dotdir Ar directory
49.Oo
50.Fl e
51.Ar method | Fl encryption Ar method
52.Oc
53.Op Fl group Ar login_group
54.Op Fl h | help | \&?
55.Op Fl home Ar partition
56.Op Fl message Ar file
57.Op Fl noconfig
58.Op Fl shell Ar shell
59.Op Fl s | silent | q | quiet
60.Op Fl uid_start Ar uid
61.Op Fl uid_end Ar uid
62.Op Fl v | verbose
63.Op Fl unencrypted
64.Ek
65.Pp
66.Nm rmuser
67.Op Ar username
68.Sh DESCRIPTION
69The
70.Nm adduser
71program adds new users to the system.
72The
73.Nm rmuser
74program removes users from the system.
75When not passed any arguments, both
76utilities operate in interactive mode and prompt for any required information.
77.Pp
78The options are as follows:
79.Bl -tag -width Ds
80.It Xo Fl batch Ar username
81.Oo Ar group Ns Op , Ns Ar group
82.Ar ... Oc
83.Op Ar fullname
84.Op Ar password
85.Xc
86Enter batch mode in which multiple users are specified on the command line
87in a compact format.
88By default the password is assumed to already be properly encrypted.
89.It Fl check_only
90Check the passwd, group, and shells databases for consistency and problems
91then exit without performing any other operation.
92.It Fl class Ar login_class
93Use the specified
94.Ar login_class
95as the default user login class.
96See
97.Xr login.conf 5
98for further details.
99.It Fl config_create
100Create or edit default configuration information and message file before
101proceeding with the normal interactive adduser procedure.
102.It Fl dotdir Ar directory
103Copy files from
104.Ar directory
105into the HOME directory of new users.
106Files named in the fashion of
107.Dq Pa dot.foo
108will be renamed to
109.Dq Pa .foo .
110By default, all files are made writable and readable by
111their owner.
112.\" don't allow group or world to write files and allow only owner
113.\" to read/execute/write .rhost, .Xauthority, .kermrc, .netrc, Mail,
114.\" prv, iscreen, term.
115.It Fl encryption , e Ar method
116Encrypt local passwords using
117.Ar method
118of encryption as described in
119.Xr login.conf 5 .
120If
121.Ar method
122is
123.Dq auto ,
124the encryption type will be derived from the user's login class.
125.It Fl group Ar login_group
126Specify the default login group.
127A value of
128.Ar USER
129means that the username is to be used as the login group.
130.It Fl help , h , \&?
131Print a summary of options and exit.
132.It Fl home Ar partition
133Specify the default home partition where all users' home directories
134are to be located.
135.It Fl message Ar file
136Send new users a welcome message from
137.Ar file .
138Specifying a value of
139.Dq no
140for
141.Ar file
142causes no message to be sent to new users.
143.It Fl noconfig
144Do not read the default configuration file.
145.It Fl shell Ar shell
146Specify the default shell for new users.
147.It Xo
148.Fl silent , s ,
149.Fl quiet , q
150.Xc
151Causes the program to print fewer warnings, questions, and bug reports.
152.It Fl uid_start Ar uid
153Use UIDs from
154.Ar uid
155up when automatically generating UIDs.
156.It Fl uid_end Ar uid
157Do not use UIDs higher than
158.Ar uid
159when generating UIDs.
160.It Fl unencrypted
161Causes the program to assume that the password given in batch mode is
162unencrypted.
163The password will be encrypted before being added to the password file.
164Use of this option is discouraged, as the username and cleartext password
165will appear in the process list, which is visible to users.
166.It Fl verbose , v
167Causes the program to print many warnings and questions.
168This option is recommended for novice users.
169.El
170.Pp
171.Nm adduser
172first performs consistency checks on the password, group, and shell databases.
173This includes finding any duplicate user or group names, illegal shells, or
174shells that aren't executable.
175Once these tests are passed,
176.Nm
177performs the following operations for each new user:
178.Bl -enum -offset indent
179.It
180Add the appropriate entries to the password and group files and re-generate
181the password database using
182.Xr pwd_mkdb 8 .
183.It
184Create a home directory and copy all files from the skeletal
185login directory (normally
186.Pa /etc/skel )
187to this new directory.
188Files named in the fashion of
189.Dq Pa dot.foo
190will be renamed to
191.Dq Pa .foo
192in the new directory.
193.It
194Mails the new user a welcome message at the discretion of the account creator.
195.El
196.Pp
197Similarly, when removing a user,
198.Nm rmuser
199performs the following operations for the given
200.Ar username :
201.Bl -enum -offset indent
202.It
203Removes any
204.Xr crontab 1
205entries or
206.Xr at 1
207jobs belonging to the user.
208.It
209Removes the user from the password database and all groups in the group
210database.
211If a group becomes empty and its name is the same as the username,
212the group is removed (this complements
213.Nm adduser Ns 's
214unique per-user groups).
215.It
216Recursively deletes all files in the user's home directory and removes the
217directory itself (provided the directory actually belongs to the user).
218.Nm rmuser
219prompts for confirmation before actually doing this.
220.It
221Removes the user's incoming mail file if one exists.
222.El
223.Pp
224Understandably,
225.Nm rmuser
226politely refuses to remove users whose UID is 0 (typically root).
227.Sh RESTRICTIONS
228.Bl -tag -width Ds
229.It Sy username
230It is recommended that login names contain only lowercase characters
231and digits.
232They may also contain uppercase characters, non-leading hyphens,
233periods, underscores, and a trailing
234.Ql $ .
235Login names may not be longer than 31 characters.
236.\" The reasons for this limit are "Historical".
237.\" Given that people have traditionally wanted to break this
238.\" limit for aesthetic reasons, it's never been of great importance to break
239.\" such a basic fundamental parameter in UNIX.
240.\" You can change UT_NAMESIZE in /usr/include/utmp.h and recompile the
241.\" world; people have done this and it works, but you will have problems
242.\" with any precompiled programs, or source that assumes the 8-character
243.\" name limit and NIS. The NIS protocol mandates an 8-character username.
244If you need a longer login name for e-mail addresses,
245you can define an alias in
246.Pa /etc/mail/aliases .
247.It Sy fullname
248This should contain the user's first name and surname.
249The
250.Ql \&:
251is not permitted.
252.It Sy login_class
253The specified user login class
254must exist in
255.Pa /etc/login.conf .
256.It Sy shell
257Only valid entries from the
258.Xr shells 5
259database or entries corresponding to
260.Xr sliplogin 8
261and
262.Xr pppd 8
263are permitted.
264.It Sy uid_start
265This value is the start of the range where free UID values are
266searched for.
267This value must be less than the value of uid_end.
268The default value is 1000 or as configured in the configuration file.
269.It Sy uid_end
270This value is the end of the range where free UID values are
271searched for.
272This value must be more than the value of uid_start.
273The default value is 2147483647 or as configured in the configuration file.
274.It Sy gid/login group
275This value is generated automatically, but can be specified at the
276discretion of the person invoking the program.
277.It Sy password
278If not empty, the password is encrypted according to
279.Xr login.conf 5 .
280If empty, the account will be automatically disabled to prevent spurious
281access to it.
282.El
283.\" .Sh UNIQUE GROUP
284.\" Perhaps you're missing what *can* be done with this scheme that falls apart
285.\" with most other schemes.  With each user in his/her own group the user can
286.\" safely run with a umask of 002 and have files created in their home
287.\" directory and not worry about others being able to read them.
288.\"
289.\" For a shared area you create a separate uid/gid (like cvs or ncvs on
290.\" freefall) you place each person that should be able to access this area
291.\" into that new group.
292.\"
293.\" This model of uid/gid administration allows far greater flexibility than
294.\" lumping users into groups and having to muck with the umask when working
295.\" in a shared area.
296.\"
297.\" I have been using this model for almost 10 years and found that it works
298.\" for most situations, and has never gotten in the way.  (Rod Grimes)
299.Sh CONFIGURATION
300.Nm
301follows these steps to extract its configuration
302information:
303.Pp
304.Bl -enum -offset indent -compact
305.It
306Read internal variables.
307.It
308Read configuration file
309.Pq Pa /etc/adduser.conf .
310.It
311Parse command-line options.
312.El
313.Pp
314The
315.Em adduser.conf
316format is explained within that file and is quite straightforward.
317.\" .Sh FORMAT
318.\" .Bl -tag -width Ds -compact
319.\" .Ql Pa #
320.\" is a comment.
321.\" .P
322.\" .It Sy config file
323.\" .Nm adduser
324.\" reads and writes this file.
325.\" See /etc/adduser.conf for more details.
326.\" .It Sy message file
327.\" Eval variables in this file. See /etc/adduser.message for more
328.\" details.
329.\" .El
330.Sh FILES
331.Bl -tag -width /etc/adduser.messageX -compact
332.It Pa /etc/master.passwd
333user database
334.It Pa /etc/group
335group database
336.It Pa /etc/shells
337shell database
338.It Pa /etc/ptmp
339lock file for the passwd database
340.It Pa /etc/adduser.conf
341configuration file for
342.Nm adduser
343.It Pa /etc/adduser.message
344message file for
345.Nm
346.It Pa /etc/skel
347skeletal login directory
348.It Pa /var/log/adduser
349log file for
350.Nm
351.El
352.Sh EXAMPLES
353Start
354.Nm
355in interactive mode:
356.Pp
357.Dl # adduser
358.Pp
359Create user
360.Dq falken
361and
362login group
363.Dq falken .
364Invite user
365.Dq falken
366into groups
367.Dq guest ,
368.Dq staff ,
369and
370.Dq beer .
371Realname (fullname)
372is
373.Dq Prof. Falken .
374The password has been created using
375.Xr encrypt 1 :
376.Bd -literal -offset indent
377# adduser -batch falken guest,staff,beer 'Prof. Falken' \e
378    $2a$06$1Sdjxjoxg4cNmT6zAxriGOLgdLXQ3HdJ2dKBbzEk68jSrO1EtLJ3C
379.Ed
380.Pp
381Create user
382.Dq vehlefanz
383in login group
384.Dq guest .
385Start the free UID search at 5000.
386No other groups, no realname, no password.
387Send a welcome message:
388.Bd -literal -offset indent
389# adduser -uid_start 5000 -group guest \e
390    -message /etc/adduser.message -batch vehlefanz
391.Ed
392.Pp
393Create user
394.Dq jsmith
395and place in the
396.Dq jsmith
397login group.
398Also add to the
399.Dq staff
400group.
401No password:
402.Pp
403.Dl "# adduser -group USER -batch jsmith staff"
404.Sh SEE ALSO
405.Xr chpass 1 ,
406.Xr finger 1 ,
407.Xr passwd 1 ,
408.Xr setlogin 2 ,
409.Xr aliases 5 ,
410.Xr group 5 ,
411.Xr login.conf 5 ,
412.Xr passwd 5 ,
413.Xr shells 5 ,
414.Xr nologin 8 ,
415.Xr pwd_mkdb 8 ,
416.Xr vipw 8 ,
417.Xr yp 8
418