CEN4020: Software Engineering I up↑

How to Use Unix Groups

 

These are basic short-cut instructions for anyone who has never used a Unix group id to set up files that can shared among (only) the members of a group.

To fully understand the commands mentioned here you should read the correspond on-line documentation ("man" pages).

First, you need a system administrator to set up a Unix group for your team. For that to happen, I need to send the Systems Group a list of group member lists, showing the userids of the members of each group, and the corresponding group name.

You can then use the chgrp, chown, and chmod commands to set permissions on files and directories, so that they are readable and/or writeable (only) by your group members. For example, to create a directory named "ourdirectory" that can be both read and modified by all members of a group named "ourgroup", but not by anyone else, you would do the following:

mkdir ourdirectory
chgrp ourgroup ourdirectory
chmod 770 ourdirectory

For a file, use "660" instead of "770". To share read permission, but not write permission, use "640" for files and "750" for directories.

You will need to take care when creating and modifying files that you maintain the desired permissions and group ownership.

To use membership in a group other than your primary group (which is probably "CS-majors") to access a file you may need to first "log in" to that group using the

newgrp

command. You will want to do this anyway when you are working on shared files, so that the group ownership will be set by default to the desired alternate group. For example, I am a member of several groups. My primary group is "fac". So, if I create a file that will be the default group owner:

baker@www.cs.fsu.edu: groups
ugcc fac webmast aces devices cybersec
baker@www.cs.fsu.edu: touch file1
baker@www.cs.fsu.edu: ls -l file1
-rw-r--r--  1 baker devices 0 Oct  1 07:48 file1

However, if I enter a sub-shell with an alternate group login, the result is different:

baker@www.cs.fsu.edu: newgrp ugcc
baker@www.cs.fsu.edu: touch file2
baker@www.cs.fsu.edu: ls -l file2
-rw-r--r--  1 baker ugcc 0 Oct  1 07:48 file2

Remember that each newgrp command creates a new (nested) subshell process, so it is a good idea to use "exit" to exit one such subshell before going into another.

($Id: groups.html,v 1.1 2010/03/22 08:48:31 baker Exp $)