Sharing files

From CsWiki
Jump to: navigation, search

By default, files in your home directory can be accessed by other users. Files in your other directories can be accessed only by yourself. (To understand why, see the umask manpage.)

The following are instructions for allowing another user to access the files within some directory.


First, use the group command to create a UNIX group.

The members of the group will be all the other users that should be able to access the files.

To create UNIX group, do:

 group

You are now within the group interactive environment. To create a group named myproj, enter:

 create myproj

To add user with login mypal to the group, enter:

add mypal

To exit the group interactive environment, enter:

 exit

The new UNIX group will be effective within five minutes. Wait for five minutes and open a new shell.

Now, change the group owner of the directory and grant access to the members of the group.

To change the group owner of directory mydir (and all its files), do

 chgrp -R myproj mydirectory

To grant read-access to mydir (and all its files) to the members of the group, do:

 find mydir -type f -exec chmod g+r {} \;
 find mydir -type d -exec chmod g+rx {} \;

Alternatively, to grant read- and write-access to mydir (and all its files) to the members of the group, do:

 find mydir -type f -exec chmod g+rw {} \;
 find mydir -type d -exec chmod g+rwx {} \;

Repeat the commands if you create a new file and/or directory under myproj. Alternatively, do:

 umask 002
 newgrp myproj

before starting to work. This ensures that any file or directory that you create will be group-writable.

Note: It is generally not a good idea that files should be writable by more than one user


For further information, see the relevant manpages.

Alternatively, use a version control system such as CVS, SubVersion or GIT.