groupmod command in linux is used to modify the information related to any existing group.
groupmod [options] GROUP
-g : option changes the group ID of the group. But, the value specified must be unique and non-negative.
For Example: An existing group in the system G1 has the group ID 983.
Next, We use -g option with groupdel to change the group ID of G1 from 983 to 9000.
-n : option changes the group name to a new one.
For Example: There exists group G1 having GID 9000 as highlighted in figure below.
Now, we change the name from G1 to Group1 (the GID remains the same).
-o : option allows having non unique GIDs. Remember, this option can be used along with -g option only.
For Example: There are two groups in my system – Group1(having GID 9000) and Group2(having GID 9001).
Next, we change the GID of Group2 to 9000. After this change both Group1 and Group2 will have the same GID i.e., 9000.
-p : options sets the password. But, this option is not recommended as the password will be visible to users.
/etc/group – contains the information about the groups in the system. Thus, you can view the contents of this file to check whether a group is there in the system or not.
/etc/gshadow – contains the secure information about the groups in the system
/etc/login.defs – Shadow password suite configuration file
/etc/passwd – contains information about user account. Thus, you can view the contents of this file to check whether a user is there in the system or not.
Q1. What is/are the benefit(s) of having same GID with -o option for multiple groups?
Q2. If the group ID of any group is changed with -g option then what happens to the files belonging to that group?