Using the group password is good for giving a user temporary access to files and directories that are owned by a particular group.

When to use?

Suppose you have a folder that is owned by a group of users all members of the same group. In this case we use “testgroup” as the group name. Lets say later you want the flexibility of giving a user that is not a member of the “testgroup” access with out adding him as a member of the group.

You can setup a group password that will grant you this level of flexibility. Below is an example of setting up a group, enabling a group password, listing the groups you are apart of, and finally changing your group membership.

Here is a good example:

[root@rhel5 ~]# groupadd testgroup
[root@rhel5 ~]# gpasswd testgroup
Changing the password for group testgroup
New Password:
Re-enter new password:
[root@rhel5 ~]# su – khightower
[khightower@rhel5 ~]$ groups
khightower
[khightower@rhel5 ~]$ newgrp testgroup
Password:
[khightower@rhel5 ~]$ groups
testgroup khightower
[khightower@rhel5 ~]$ exit
exit
[khightower@rhel5 ~]$ groups
khightower
[khightower@rhel5 ~]$

You can tell from the commands that a new group “testgroup” was created by the root user. A password was then assigned to the “testgroup”.

I switched to another user (khightower) account that is not a member of “testgroup”. Next I list my current group membership with the groups command.

Then change to the “testgroup” using the following:

[khightower@rhel5 ~]$ newgrp testgroup

*If you are not listed as a member of the group you are changing to, you must supply a password.

When finished, you can enter “exit”, and return to your normal group. I then used the groups command again to list my current group membership.