I\'m having two directories: \"public\" and \"private\". I have three users: \"chris\", \"john\", \"dan\". I have two groups: \"pub\", \"priv\" and \"god\".
There are two problematic things in your approach. The first one is:
chgrp god public private
chgrp pub public
With second command, you discarded the effect of the first one. Directory public
now belongs to pub
group, not to god
anymore.
The second thing is that you probably didn't give write permissions on directory public
to group that owns it (the fact that the user executing the command touch
belongs to directory's group doesn't matter).
Try this:
chmod 770 public
and do similar with other directories. However, what you're initially trying to achieve is impossible because the directory can belong to one group only. Nikos elaborated it well in his answer - place user in more groups.