2 chmod permissions incorrect
source | link

The default behaviour (as you have found out) is to give a file the same UID and GID as the owner. If you want to override that, you need to set the setgid bit on the directory that stores the file. This will not affect already-existing files and directories, so you'll need to fix the permissions on each directory underneath as well (as @cas mentioned, you probably want to allow the members of the foo group to modify each others' work (and view the directories), so you'll want to add those permissions too.)

To fix this (assuming you've already created the directory structure), run the following from the root of the structure:

find . -type d -exec chmod u+sg=rwsX {} \;
chgrp -R foo *

I used find to select just the directories, as setting the setuid/setgid bits on files has a different meaning. Of course, if you're creating a new directory, you just have to run the chmod/chgrp commands without using find.

EDIT: Fixed the chmod permissions.

The default behaviour (as you have found out) is to give a file the same UID and GID as the owner. If you want to override that, you need to set the setgid bit on the directory that stores the file. This will not affect already-existing files and directories, so you'll need to fix the permissions on each directory underneath as well.

To fix this (assuming you've already created the directory structure), run the following from the root of the structure:

find . -type d -exec chmod u+s {} \;
chgrp -R foo *

I used find to select just the directories, as setting the setuid/setgid bits on files has a different meaning. Of course, if you're creating a new directory, you just have to run the chmod/chgrp commands without using find.

The default behaviour (as you have found out) is to give a file the same UID and GID as the owner. If you want to override that, you need to set the setgid bit on the directory that stores the file. This will not affect already-existing files and directories, so you'll need to fix the permissions on each directory underneath as well (as @cas mentioned, you probably want to allow the members of the foo group to modify each others' work (and view the directories), so you'll want to add those permissions too.)

To fix this (assuming you've already created the directory structure), run the following from the root of the structure:

find . -type d -exec chmod g=rwsX {} \;
chgrp -R foo *

I used find to select just the directories, as setting the setuid/setgid bits on files has a different meaning. Of course, if you're creating a new directory, you just have to run the chmod/chgrp commands without using find.

EDIT: Fixed the chmod permissions.

1
source | link

The default behaviour (as you have found out) is to give a file the same UID and GID as the owner. If you want to override that, you need to set the setgid bit on the directory that stores the file. This will not affect already-existing files and directories, so you'll need to fix the permissions on each directory underneath as well.

To fix this (assuming you've already created the directory structure), run the following from the root of the structure:

find . -type d -exec chmod u+s {} \;
chgrp -R foo *

I used find to select just the directories, as setting the setuid/setgid bits on files has a different meaning. Of course, if you're creating a new directory, you just have to run the chmod/chgrp commands without using find.