USERADD(8) | System Manager's Manual | USERADD(8) |
useradd
— add a
user to the system
useradd |
-D [-b
base-directory] [-e
expiry-time] [-f
inactive-time] [-g
gid | name |
=uid ] [-k
skel-directory] [-L
login-class] [-r
low..high]
[-s shell] |
useradd |
[-mov ] [-b
base-directory] [-c
comment] [-d
home-directory] [-e
expiry-time] [-f
inactive-time] [-G
secondary-group[,group,...]]
[-g gid |
name | =uid ]
[-k skel-directory]
[-L login-class]
[-p password]
[-r
low..high]
[-s shell]
[-u uid]
user |
The useradd
utility adds a user to the
system, creating and populating a home directory if necessary. Any skeleton
files will be provided for the new user if they exist in the
skel-directory directory (see the
-k
option). Default values for the base directory,
the time of password expiry, the time of account expiry, primary group, the
skeleton directory, the range from which the UID will be allocated, and
default login shell can be provided in the
/etc/usermgmt.conf file, which, if running as root,
is created using the built-in defaults if it does not exist.
The first form of the command shown above (using the
-D
option) sets and displays the defaults for the
useradd
utility.
-b
base-directory-m
option
is specified and no -d
option is specified.-D
-D
will show the
current defaults which will be used by the useradd
utility. Together with one of the options shown for the first version of
the command, -D
will set the default to be the new
value. See
usermgmt.conf(5) for
more information.-e
expiry-time-f
inactive-time-e
option above.-g
gid | name |
=uid
-k
skel-directory-L
login-class-r
low..high-s
shellIn the second form of the command, after setting any defaults, and then reading values from /etc/usermgmt.conf, the following command line options are processed:
-b
base-directory-m
option be
specified.-c
comment-d
home-directory-m
option be specified.-e
expiry-time-f
inactive-time-e
option above.-G
secondary-group[,group,...]-g
gid | name |
=uid
=uid
, then a
UID and GID will be picked which are both unique and the same, and a line
added to /etc/group to describe the new
group.-k
skel-directory-L
login-class-m
-o
-p
password-s
shell-u
uid-v
Once the information has been verified,
useradd
uses
pwd_mkdb(8) to update the
user database. This is run in the background and, at very large sites, could
take several minutes. Until this update is completed, the password file is
unavailable for other updates and the new information is not available to
programs.
The useradd
utility exits 0 on
success, and >0 if an error occurs.
chpass(1), group(5), login.conf(5), passwd(5), usermgmt.conf(5), pwd_mkdb(8), user(8), userdel(8), usermod(8)
Other implementations of the useradd
utility use the inactive-time parameter to refer to
the maximum number of days allowed between logins (this is used to lock
"stale" accounts that have not been used for a period of time).
However, on OpenBSD systems this parameter refers
instead to the password change time. This is due to differences in the
passwd(5) database compared
to other operating systems.
The useradd
utility first appeared in
OpenBSD 2.7.
The useradd
utility was written by
Alistair G. Crooks
<agc@NetBSD.org>.
November 29, 2016 | OpenBSD-6.9 |