Modifying Groups

Managing Groups with groupmod

The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry within the group database.



Groupmod Command available Options


Below are the options that can be used by the "groupmod" command.


Usage: groupmod [options] GROUP

Options:
  -g, --gid GID                 change the group ID to GID
  -h, --help                    display this help message and exit
  -n, --new-name NEW_GROUP      change the name to NEW_GROUP
  -o, --non-unique              allow to use a duplicate (non-unique) GID
  -p, --password PASSWORD       change the password to this (encrypted)
                                PASSWORD


Change the GID of an existing group


groupmod -g New_GID Group


[root@fedsrv01a ~]# grep testgroup /etc/group
testgroup:x:1005:

[root@fedsrv01a ~]# groupmod -g 1010 testgroup

[root@fedsrv01a ~]# grep testgroup /etc/group
testgroup:x:1010:

In the above example we used the "groupmod" command with the "-g" option to specify a new GID for an existing group. In the example the GID was changed to "1010" from its original value of "1005".


Change the name of an existing group


groupmod -n New_Group Old_Group


[root@fedsrv01a ~]# groupmod -n supergroup testgroup

[root@fedsrv01a ~]# grep supergroup /etc/group
supergroup:x:1010:

In the above example, the option "-n" was used to specify a new name for an existing group. The groupname "testgroup" was changed to "supergroup".