3.32. Changing Groups: newgrpIf you're a member of several groups and then you create a file, to what group does the file belong? Well, although you may be a member of several groups, only one of them is your effective group at any given time. When a process creates a file, the group ID of the file is set to the process's effective group ID. This means that when you create a file from the shell, the group ID of the file is set to the effective group ID of your shell. In this example session, I was a member of the "cs" and "music" groups, and my login shell's effective group name was "cs." The system administrator is the one who chooses which one of your groups is used as your login shell's effective group ID. The only way to permanently alter your login shell's effective group ID is to ask the system administrator to change it. However, you may create a shell with a different effective group ID by using the newgrp utility (Figure 3-44).
In the following example, I created a file called "test1" from my login shell, which had an effective group of "cs." I then created a temporary shell with an effective group of "music" and then created a file called "test2." I then terminated the shell and went back to the original shell, where I obtained a long listing of both files: $ date > test1 ...create from a "cs" group shell. $ newgrp music ...create a "music" group shell. $ date > test2 ...create from a "music" group shell. ^D ...terminate the new shell. $ ls -l test1 test2 ...look at each file's attributes. -rw-r--r-- 1 glass cs 29 Jan 31 22:57 test1 -rw-r--r-- 1 glass music 29 Jan 31 22:57 test2 $ _ |