Connecting Tech Pros Worldwide Forums | Help | Site Map

How do you change a user's primary group as they change directory

Newbie
 
Join Date: Feb 2009
Posts: 1
#1: Feb 4 '09
User1 is a member of Group1, Group2 and Group3, each group has a directory (say /home/group1, /home/group2, ...)

How do I make it so that when User1 cds to /home/group1, their primary group becomes group1, when they cd to group2 they become group2, etc?

Essentially, I'm only looking to do this so that when User1 makes a new file in each respective directory, it can be set group writable for the appropriate group.

I will be doing this on Solaris 10 (Although I am testing on Ubuntu 8.10...)

Thanks!

kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#2: Feb 5 '09

re: How do you change a user's primary group as they change directory


I suggest that u set up a cron that updates the permission once a file is created or check for any new file in the corresponding directory and update its permissions.
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#3: Feb 5 '09

re: How do you change a user's primary group as they change directory


Another option would be to overload the cd command with a local script, so that if checks if the directory that it's changing to is in one of these places and if so change the default group.

Greetings,
Nepomuk
Reply

Tags
file permissions, unix