Linux groupadd Command
The groupadd
command is used to create a new group. The information of the new group will be added to the system files.
Related Files:
/etc/group: Group account information.
/etc/gshadow: Secure group account information.
/etc/login.defs: Shadow password suite configuration.
Syntax
The syntax for the groupadd
command is as follows:
groupadd [-g gid [-o]] [-r] [-f] group
Parameter Description:
-g: Specify the id of the new group;
-r: Create a system group, the group ID of the system group is less than 500;
-K: Overwrite the configuration file /etc/login.defs;
-o: Allow adding a group with a non-unique group ID.
-f, --force: If the specified group already exists, this option will fail silently and exit with a success status. When used with -g, and the specified GID_MIN already exists, another unique GID will be selected (i.e., -g is turned off).
Example
Create a new group and add a group ID.
# groupadd -g 344 tutorialpro
This will create a group with a group ID (GID) of 344 in the /etc/group file.