Information Technology Reference
In-Depth Information
Table 3.3
Command-Line Arguments for the useradd Command
(continued)
Argument
Description
-g
group
Defines the GID or name of an existing
group
that will be the pri-
mary group for the user account.
-G
group
Defines a GID or name of an existing
group
that will be a second-
ary group for the user account.
-k
template_dir
Specifies the directory that contains a template (default) profile
used for the user account.
-m
Creates the home directory if it doesn't exists. The home directo-
ry is defined by
-b
and
account
name or
-d
.
-o
Allows an existing UID to be specified. That is, it allows an
account to be created with a duplicate UID (see
-u
).
-p
profiles
Specifies one or more execution
profiles
.
-R
roles
Specifies one or more user
roles
.
-s
shell
Specifies the login shell; default is the Bourne Shell (
/bin/sh
).
-u
uid
Specifies the UID of the user account. It must be a decimal inte-
ger. If not specified, the next highest available UID is assigned.
The following example shows how to create a user account using the
useradd
command:
# useradd -d /export/home/user1 -m -g other -u 1050 user1
6 blocks
#
This command creates the
user1
user account, assigns it UID 1050, makes it
a member of group
other
and creates its home directory
/export/home/user1
.
To make life a little easier, the
useradd
command also supports the
-D
command-line argument, which allows default values to be assigned to
authorizations (
-A
), base directory (
-b
), group (
-g
), expiration date (
-e
), max-
imum inactivity (
-f
), execution profile (
-P
), and role (
-R
). Subsequent uses of
the
useradd
command will use these default values if they are not specified.
For example, the following command can be used to assign a default base
directory and default group. Whenever defaults are assigned or changed, the
new defaults are listed:
# useradd -D -b /export/home -g other
group=other,1 project=,3 basedir=/export/home
skel=/etc/skel shell=/bin/sh inactive=0
expire= auths= profiles= roles=
#
# useradd -m -u 1051 user2
6 blocks
#