kazmax - Home Server on Linux

Linux Create a new group - groupadd

To create a new group on Linux, use the command groupadd.

The files change by the groupadd command are two files "/etc/group" and "/etc/gshadow". Also run the groupadd command with "root" account.

Last Update : December 19, 2018

Linux Create a new group - groupadd Contents

  1. Create a group with "groupadd" command.
  2. Specify GID and create group with "groupadd" command.
  3. About "groupadd" command options, and related files.

1. Create a group with "groupadd" command.

To create a group with the groupadd command, proceed as follows.

Usage

groupadd group_name

Example) When creating bar_group.

[root@localhost ~]# groupadd bar_group
[root@localhost ~]# tail -1 /etc/group
bar_group:515:
↑ A line of bar_group was added to the /etc/group file.

2. Specify GID and create group with "groupadd" command.

To create a group by specifying a GID with the groupadd command, do as follows.

Usage

groupadd -g GID group_name

GID is the identifier of the group that the system internally uses. Basically, you specify a unique value.

GID can be checked from /etc/group file. For details of the contents of the /etc/group file, see How to check the Linux group list and about /etc/group file.

Example) When creating bar_group as GID 520.

[root@localhost ~]# groupadd -g 520 bar_group
[root@localhost ~]# tail -1 /etc/group
bar_group:520:
↑ bar_group is added as GID is 520.

3. About "groupadd" command options, and related files.

Files change by the groupadd command are two files "/etc/group" and "/etc/gshadow".

Even if you directly modify these files without using the groupadd command, the system recognizes them as a group.