1

I have created a new group called "city". Added 2 users in that group:

  • admin
  • moderator

Changed the owner/group of a folder:

chown -R admin:city /folder

Changed permissions:

chmod -R g+ws /folder

So the group users could read & edit all files within this folder. However when user "moderator" creates a new file it gets following owners:

  • group: city
  • owner: moderator

That means a user "admin" cannot edit that file without sudo. How to force group users to create a file as "admin"?

1

You already have setgid on the directory, so anything created in it inherits the group ownership. Since Linux ignores setuid on directories, set the umask for the user to make new files group-writable:

umask 0002
  • Thanks, but it gets "moderator:city" not "admin:city" any ideas? – Alexander Kim Oct 26 '14 at 10:18
  • @Heihachi a new file gets moderator:city? Are you sure the owner of the directory is admin? – muru Oct 26 '14 at 10:19
  • drwsrwsr-x 9 admin city /folder. When "moderator" creates a new file within that folder it gets -rw-r--r-- 1 moderator city text.file. So "admin" cannot edit that file. – Alexander Kim Oct 26 '14 at 10:22
  • 1
    @Heihachi Ack, I was mistaken. setuid is ignored in Linux on directories. Your next option is to modify the umask of moderator, so that newly created files have g+w. – muru Oct 26 '14 at 10:24
  • so setuid is not necessary in my case? Edit your answer, please. So the rest people who came across that issue will see that, thanks. I've ended up with using umask in each user's .bashrc – Alexander Kim Oct 26 '14 at 10:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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