LinuxCommandLibrary

groupadd

Create a new group

TLDR

Create a new group

$ sudo groupadd [group_name]
copy

Create a new system group
$ sudo groupadd [[-r|--system]] [group_name]
copy

Create a new group with the specific groupid
$ sudo groupadd [[-g|--gid]] [id] [group_name]
copy

SYNOPSIS

groupadd [options] group

PARAMETERS

-g GID
    Specify the numerical group ID (GID). Must be a non-negative integer and unique.

-o
    Allow a non-unique GID. This is generally discouraged.

-r
    Create a system group. System groups typically have GIDs less than a defined value and are used for system services.

-f
    Forces the groupadd command to exit successfully if the group already exists, and cancel the command execution.

-K KEY=VALUE
    Override default values defined in /etc/login.defs

group
    The name of the new group to create.

DESCRIPTION

The groupadd command in Linux is used to create a new group account. It adds a new entry to the /etc/group file (and optionally to other relevant database files like /etc/gshadow) with the specified group name (GID). The group name must be unique. The command provides options to specify the group ID (GID) or let the system automatically assign one. When creating a new group, the system admin must ensure that the chosen GID doesn't conflict with existing GIDs to maintain system integrity. The command offers flexibility, enabling the setup of new groups with specific configurations to align with user and access management needs within the Linux environment.
Proper usage of this command requires root privileges or suitable permissions, ensuring only authorized users can modify the system's group database.

CAVEATS

Care must be taken when manually specifying a GID using the -g option. Using a GID that is already in use can cause serious system problems.
The group name must follow naming conventions such as beginning with a letter or underscore, and it should not contain special characters.

EXIT STATUS

The groupadd command exits with the following values:
0 - success
>0 - failure

SEE ALSO

groupdel(8), groupmod(8), useradd(8), userdel(8), usermod(8)

Copied to clipboard