xref: /openbsd/usr.sbin/adduser/adduser.8 (revision 264ca280)
1.\"	$OpenBSD: adduser.8,v 1.44 2015/12/24 16:54:37 mmcc 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: December 24 2015 $
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 email 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 pppd 8
261are permitted.
262.It Sy uid_start
263This value is the start of the range where free UID values are
264searched for.
265This value must be less than the value of uid_end.
266The default value is 1000 or as configured in the configuration file.
267.It Sy uid_end
268This value is the end of the range where free UID values are
269searched for.
270This value must be more than the value of uid_start.
271The default value is 2147483647 or as configured in the configuration file.
272.It Sy gid/login group
273This value is generated automatically, but can be specified at the
274discretion of the person invoking the program.
275.It Sy password
276If not empty, the password is encrypted according to
277.Xr login.conf 5 .
278If empty, the account will be automatically disabled to prevent spurious
279access to it.
280.El
281.\" .Sh UNIQUE GROUP
282.\" Perhaps you're missing what *can* be done with this scheme that falls apart
283.\" with most other schemes.  With each user in his/her own group the user can
284.\" safely run with a umask of 002 and have files created in their home
285.\" directory and not worry about others being able to read them.
286.\"
287.\" For a shared area you create a separate uid/gid (like cvs or ncvs on
288.\" freefall) you place each person that should be able to access this area
289.\" into that new group.
290.\"
291.\" This model of uid/gid administration allows far greater flexibility than
292.\" lumping users into groups and having to muck with the umask when working
293.\" in a shared area.
294.\"
295.\" I have been using this model for almost 10 years and found that it works
296.\" for most situations, and has never gotten in the way.  (Rod Grimes)
297.Sh CONFIGURATION
298.Nm
299follows these steps to extract its configuration
300information:
301.Pp
302.Bl -enum -offset indent -compact
303.It
304Read internal variables.
305.It
306Read configuration file
307.Pq Pa /etc/adduser.conf .
308.It
309Parse command-line options.
310.El
311.Pp
312The
313.Em adduser.conf
314format is explained within that file and is quite straightforward.
315.\" .Sh FORMAT
316.\" .Bl -tag -width Ds -compact
317.\" .Ql Pa #
318.\" is a comment.
319.\" .P
320.\" .It Sy config file
321.\" .Nm adduser
322.\" reads and writes this file.
323.\" See /etc/adduser.conf for more details.
324.\" .It Sy message file
325.\" Eval variables in this file. See /etc/adduser.message for more
326.\" details.
327.\" .El
328.Sh FILES
329.Bl -tag -width /etc/adduser.messageX -compact
330.It Pa /etc/master.passwd
331user database
332.It Pa /etc/group
333group database
334.It Pa /etc/shells
335shell database
336.It Pa /etc/ptmp
337lock file for the passwd database
338.It Pa /etc/adduser.conf
339configuration file for
340.Nm adduser
341.It Pa /etc/adduser.message
342message file for
343.Nm
344.It Pa /etc/skel
345skeletal login directory
346.It Pa /var/log/adduser
347log file for
348.Nm
349.El
350.Sh EXAMPLES
351Start
352.Nm
353in interactive mode:
354.Pp
355.Dl # adduser
356.Pp
357Create user
358.Dq falken
359and
360login group
361.Dq falken .
362Invite user
363.Dq falken
364into groups
365.Dq guest ,
366.Dq staff ,
367and
368.Dq beer .
369Realname (fullname)
370is
371.Dq Prof. Falken .
372The password has been created using
373.Xr encrypt 1 :
374.Bd -literal -offset indent
375# adduser -batch falken guest,staff,beer 'Prof. Falken' \e
376    $2a$06$1Sdjxjoxg4cNmT6zAxriGOLgdLXQ3HdJ2dKBbzEk68jSrO1EtLJ3C
377.Ed
378.Pp
379Create user
380.Dq vehlefanz
381in login group
382.Dq guest .
383Start the free UID search at 5000.
384No other groups, no realname, no password.
385Send a welcome message:
386.Bd -literal -offset indent
387# adduser -uid_start 5000 -group guest \e
388    -message /etc/adduser.message -batch vehlefanz
389.Ed
390.Pp
391Create user
392.Dq jsmith
393and place in the
394.Dq jsmith
395login group.
396Also add to the
397.Dq staff
398group.
399No password:
400.Pp
401.Dl "# adduser -group USER -batch jsmith staff"
402.Sh SEE ALSO
403.Xr chpass 1 ,
404.Xr finger 1 ,
405.Xr passwd 1 ,
406.Xr setlogin 2 ,
407.Xr aliases 5 ,
408.Xr group 5 ,
409.Xr login.conf 5 ,
410.Xr passwd 5 ,
411.Xr shells 5 ,
412.Xr nologin 8 ,
413.Xr pwd_mkdb 8 ,
414.Xr vipw 8 ,
415.Xr yp 8
416