Linux Commands – groupadd

Linux Commands – groupadd

Linux Commands – groupadd

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed date command in Linux which is used to displays the current time in the given FORMAT, or set the system date.

https://cloudaffaire.com/linux-commands-date/

In this blog post, we will discuss groupadd command in Linux. groupadd command is used to create a new group in Linux. A group represents a collection of users and is used to manage multiple users at once. Whenever you add a user into a group, the user inherits the group properties from the group. A user can be member of multiple groups at once. Each group has a name and id assosiated with it and optionally you can assign a password as well. Groups can be system generated or user defined. You need to have root or sudo privilege to create a group. A group name can be up to 32 characters long. Group configurations are stored in /etc/login.defs file.

Group Configuration:

  • GID_MAX (number), GID_MIN (number): Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers. The default value for GID_MIN (resp. GID_MAX) is 1000 (resp. 60000).
  • MAX_MEMBERS_PER_GROUP (number): Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group.
  • SYS_GID_MAX (number), SYS_GID_MIN (number): Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers.

Group Files:

  • /etc/group: Group account information.
  • /etc/gshadow: Secure group account information.
  • /etc/login.defs: Shadow password suite configuration.

Linux Commands – groupadd:

You can use groupadd command to create a new group.

You can use groupadd -f or –force options 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).

You can use groupadd -g GID or –gid GID options to define a custom group id for your group. The GID value must adhere to group configuration defined in /etc/login.defs file. 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 or equal to GID_MIN and greater than every other group.

You can use groupadd -K or –key KEY=VALUE options to override /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple -K options can be specified.

You can use groupadd -o or –non-unique options which permit to add a group with a non-unique GID.

You can use groupadd -p or –password PASSWORD options to define a password for the group, default is to disable password for group. Please note that the password is secure and can be listed.

You can use groupadd -r or –system options to define a system group. There is no difference between a normal group and system group, only the numeric identifiers of new system groups are chosen in the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs, instead of GID_MIN-GID_MAX.

Hope you have enjoyed this article. In the next blog post, we will discuss groupmod command in Linux.

 

Leave a Reply

Close Menu