groupadd- Unix, Linux Command



NAME

groupadd - Creates a new group.

SYNOPSIS

groupadd [options] group

DESCRIPTION

groupadd command creates a new group account using the values specified on the command line and the default values from the system. The new group will be entered into the system files as needed.

Options

Tag Description
-f, --force This option causes the command to simply exit with success status if the specified group already exists. When used with -g, and the specified GID already exists, another (unique) GID is chosen (i.e. -g is turned off).
-r, --system Create a system group.

The numeric identifiers of new system groups are choosen in the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs, instead of GID_MIN-GID_MAX.

-g, --gid GID The numerical value of the group's ID. This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater than 999 and greater than every other group. Values between 0 and 999 are typically reserved for system accounts.
-h, --help Display help message and exit.
-K, --key KEY=VALUE Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple -K options can be specified.

Example: -K GID_MIN=100 -K GID_MAX=499

Note: -K GID_MIN=10,GID_MAX=499 doesn't work yet.

-o, --non-unique This option permits to add a group with a non-unique GID.
-p, --password PASSWORD The encrypted password, as returned by crypt. The default is to disable the password.

EXAMPLES

Example-1:

This example would create a new group called "newgroup".

# groupadd newgroup

output:

to verify greoup created , search in /etc/group

# grep test /etc/group
test:x:1002:

Example-2:

To create new group with specific groupid

#  groupadd -g 9090 newgroup

output:

# grep newgroup /etc/group
newgroup:x:9090:

Example-3:

To create group in user defined range ( not range from system i.e /etc/login.defs)

# groupadd newgroup -K GID_MIN=8888 -K GID_MAX=9999

output:

# grep newgroup /etc/group
newgroup:x:9091:

Print
Advertisements