Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

OS: Ubuntu 12.04

I have a directory what has given write permission to group foo. Two users bar and baz are part of the group. Both can successfully write files to the directory. However, baz cannot overwrite a file (i.e. create a file with the same name) that was written by bar. I'm doing the file I/O through Python (csv module), but I don't think that has anything to do with this problem.

How do I set permissions so that bar and baz can overwrite eachother's files in the foo directory?

Thanks.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You can change the mode of the directory to setgid to ensure that new files are created with the same group as that owning the directory. See this article for more information: http://en.wikipedia.org/wiki/Setuid .

The command is: chmod g+s /path/to/directory

share|improve this answer

When user creates file, the default permissions don't allow write to group. You need to change the umask so newly created files will have write permissions for group:

umask 0002

To know what is the current umask, run it without args.

See man umask for more info.

share|improve this answer
    
Thanks @shimon! I just ran umask in the foo directory with no args, it returned 0002 –  NP01 Feb 12 '13 at 7:33
    
AFAIK, You set it once and it persists until you change it.. –  Shimon Rachlenko Feb 12 '13 at 7:34
    
umask only limits the max permissions so if the application doesn't request group write then umask has no effect. –  Iain Feb 12 '13 at 7:35

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.