Shared directories

Last edit

Changed:

< Sometimes you need a couple of users to share a directory, for example a number of developers who test in their own directory but deploy to a central directory. As an example, we'll take the /var/www directory, which we assume is already present on the system. Take the following steps.

to

> Sometimes you need a couple of users to share a directory, for example a number of developers who test in their own directory but deploy to a central directory. As an example, we'll take the /var/www directory, which we assume is already present on the system.

Changed:

< There is no way to set a property on the directory forcing newly created files to have the group write bit.

to

> ''There is no way to set a property on the directory forcing newly created files to have the group write bit.''
> Setting the umask in .bashrc will not affect the way that directories and files are created in desktop environments. This is outlined below
.

Changed:

< Under Debian, you can create a file called $HOME/.gnomerc and add the line

to

> Under Debian and Ubuntu, you can create a file called $HOME/.gnomerc and add the line
> umask 002
> I have not tested this under other distributions.
> = KDE =
> Under Debian and Ubuntu, you can create a directory called $HOME/.kde/env and add files there. Name the file for example "rights.sh" and add one line:


Sometimes you need a couple of users to share a directory, for example a number of developers who test in their own directory but deploy to a central directory. As an example, we'll take the /var/www directory, which we assume is already present on the system.

First create a common group:

  # groupadd wwwdev

Then add all users to this group:

  # usermod -a -G wwwdev user1
  # usermod -a -G wwwdev user2
  ... et cetera

Change the group of the directory and do the same for all underlying files and directories:

  # chgrp -R wwwdev /var/www

Find the directory and all subdirectories. Set the setgid bit on the directory (which makes sure that new files are owned by the group), and also make sure the directory is readable, writeable and accessible:

  # find /var/www -type d -exec chmod g+srwx {} \;

At this point, all directories can be written to by everyone in the group. Now make all files writeble as well.

  # chmod -R g+w /var/www

To let users easily edit each others documents, it's best they set the umask to 002 instead of the usually default 022. In the shell initialization file (for instance .bashrc), add the line

  umask 002

Tip: if users encounter a file where the group does not have write permission, it's easily fixed by the individual user copying the other user its file, deleting the original and renaming the copy back to the original name.

There is no way to set a property on the directory forcing newly created files to have the group write bit.

Setting the umask in .bashrc will not affect the way that directories and files are created in desktop environments. This is outlined below.

Gnome

Under Debian and Ubuntu, you can create a file called $HOME/.gnomerc and add the line

  umask 002

I have not tested this under other distributions.

KDE

Under Debian and Ubuntu, you can create a directory called $HOME/.kde/env and add files there. Name the file for example "rights.sh" and add one line:

  umask 002

I have not tested this under other distributions.