You can modify group properties in Linux using the groupmod command. This command allows you to change the name or GID (Group ID) of an existing group.
Basic Syntax
groupmod [options] group_name
Options
Change Group Name:
- To change the name of a group, use the
-noption:
groupmod -n new_group_name old_group_name- To change the name of a group, use the
Change Group ID:
- To change the GID of a group, use the
-goption:
groupmod -g new_gid group_name- To change the GID of a group, use the
Examples
Change Group Name: To change the group name from
oldgrouptonewgroup:sudo groupmod -n newgroup oldgroupChange Group ID: To change the GID of the group
mygroupto1001:sudo groupmod -g 1001 mygroup
Summary
The groupmod command is a powerful tool for modifying existing group properties, allowing you to change group names and GIDs as needed. Always ensure you have the necessary permissions (usually root) to make these changes.
