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 Answer 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? Oct 26, 2014 at 10:18
  • @Heihachi a new file gets moderator:city? Are you sure the owner of the directory is admin?
    – muru
    Oct 26, 2014 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. Oct 26, 2014 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, 2014 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 Oct 26, 2014 at 10:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .