groupmod command is used to modify a group’s information on a Linux system. This includes changing the group’s name or ID, as well as modifying its password, membership, or other attributes.
groupmod command can be used to change the name or ID of an existing group. To change a group’s name, use the
-n option followed by the new name:
$ sudo groupmod -n newgroupname oldgroupname
To change a group’s ID, use the
-g option followed by the new ID:
$ sudo groupmod -g newgroupid groupname
It is important to note that changing a group’s ID may have unintended consequences, such as invalidating permissions or ownership of files that are associated with the group.
Other options available with the
groupmod command include:
-o: Allow duplicate group IDs to be created
-p: Set the group’s password to the specified encrypted password
-A: Add a user to the group
-R: Remove a user from the group
-g: Set the group ID to the specified value
-n: Set the group name to the specified value
The following table lists the available options for the
||Allow duplicate group IDs to be created|
||Set the group’s password to the specified encrypted password|
||Add a user to the group|
||Remove a user from the group|
||Set the group ID to the specified value|
||Set the group name to the specified value|
- If you receive an error message stating that the group does not exist, make sure that you have entered the correct group name or ID.
- If you change a group’s ID, be aware that this may affect file permissions and ownership. Make sure to update any affected files accordingly.
- If you receive a permission denied error, make sure that you are running the
groupmodcommand with root privileges using
groupmodcommand can also be used to modify a group’s GID (group identification number) in
groupmodcommand can be used in conjunction with other commands, such as
usermod, to manage user and group accounts on a Linux system.