Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a file that a colleague and I are editing together, on a Unix system. We are using Unix group permissions to edit it. We have one Unix group that we are both members of. Whenever I save the file, it changes the Unix group to one that he is not a member of. Is there any way to stop it from doing that?

share|improve this question

migrated from stackoverflow.com Jun 16 '11 at 18:21

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 10 down vote accepted

Your options are to set the setgid bit (chmod g+s) on the directory to make files created within it match its group ID, or to use the newgrp command to open a shell with the desired group ID before editing the file.

share|improve this answer
1  
I'm not sure this is correct. I think what the what he needs is the setgid bit, not to the sticky bit. From Wikipedia: Setting the setgid permission on a directory (chmod g+s) causes new files and subdirectories created within it to inherit its group ID, rather than the primary group ID of the user who created the file. Activating the sticky bit on the directory will only make sure that only the directories' files' owner, the directory's owner or root can modify the directories' files. –  user815423426 Oct 21 '11 at 23:09

One option is to switch group using the command newgrp. It may ask for the group password that you may set with gpasswd.

share|improve this answer

Uno. change your default login group number to be the same between the two people

username:x:500:514::/home/username:/bin/tcsh
# Where 514 is the group id.

Duo: create a new user id , with a password only known by the two people involved. chown the file to be owned by the new userid. Before editing the file in question, suto the new userid.

Trio:.

cp $EDITOR to $HOME; \# in this example pico
chmod g+s $HOME/pico;
chgrp RELEVANTGROUP $HOME/pico;

Quattro:

sudo chgrp RELEVANTGROUP some/path/to/file \# may require root

Cinco: Create a few Google account and edit the thing SIMULTANEOUSLY in Google docs. (it is neat to watch where the other person is typing). Make a point of changing the sharing perms in Google Docs for "anyone with the link"

Hexo: Split the file in two and have each editor only work on half.

share|improve this answer

Take a look at umask on your system.

share|improve this answer
    
OK, default dot files set by our sys admins use a umask of 022. What's a good umask for "don't change it!"? –  asbruckman Mar 13 '09 at 14:22
2  
umask is for default permissions, not group ID. –  moonshadow Mar 13 '09 at 14:33

Here is a good article about Sticky-Bit and other advanced permission settings: http://www.cs-repository.info/p/tutorial.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.