Sharing a directory of files

Directories and files should be shared via a common group access. Sharing directories or files by allowing world writes access is a bad idea.

You and the person with whom you wish to share files should determine the likely group to use with the groups command. (That is, type "groups" or "groups username" For all the groups you have in common, you can determine all the users in each group with the ypmatch command:

   ypmatch group-name group
Determine which group to use. If none is sufficiently restrictive, you may have to ask your sysadmin to allocate a private group for your usage. Let's call this group sharegrp.

First, build the directory, which we'll call sharedir:

   mkdir sharedir
Then, put the directory into the group being used for sharing, give group full access, and ensure that files created in that directory are in the shared group:
   chgrp sharegrp sharedir
   chmod g+rwxs sharedir

The last thing to remember is to be sure the second digit of your umask is zero when working in the shared directory. You can display your current umask by just typing

   umask
(The umask is a 3 digit number indicating which bits of a program's suggested protection to clear in order to get the actual protection to use when creating a file.) If the above command showed your umask to be anything other than 7 (eg, 27, which is actually 027), change the middle digit to 0 and issue the command
   umask 007
This means that files you create will have group read/write/execute access. You might want to define some aliases for your .cshrc, such as
   alias   share     "umask 007 ; cd ~/sharedir"
   alias   unshare   "umask 027 ; cd"
Something else you want to consider when sharing a directory within a group is that anyone with write access to a directory can rename or delete any files within that directory, regardless of the file's permissions. But if you set the "sticky" bit on the directory
   chmod +t sharedir
rename/delete access to files within the directory is determined by the protection of the files themselves.
This page last updated June 28, 2000.