I am trying to setup a directory /opt/www in such a way that when a user who belongs to the group django creates/modifies files and directorys within, they are set to owner django and group django.

I have looked at setuid and setgid confusion and Special File Permissions (setuid, setgid and Sticky Bit)

From this I chmod 6775 /opt/www However touch /opt/www/test yeilds

-rw-rw-r-- 1 wurst django 0 Mar 16 13:58 test

Q) How do I implement this requirement of having any user that belongs to group django, and creates a file or folder within /opt/www, to have it automaticaly chown django:django? (not :django)

Secondly, I am curious if this is nessisary for security purposes or if simply doing a chown -R :django and not worying about the owner beingt he user who created the file.

Note: in addition to creating the group django and adding my regular user account to this group, I have also created a system user via useradd -rg django django

Im oposed to storing my project within my home directory, although this will be on a live site, the site itself wont see much traffic as It will not be submiting it to search engines not premoted. Its sole purpose in life it as a learning platform for myself.

What might I be doing wrong? Do i need to write a custom script and schedule a cron job for it?

  • Related question: How do you get linux to honor setuid directories?. TL;DR: Linux ignores setuid on directories, so you'll need to use alternative means if it's important (test to find out!)
    – ErikF
    Mar 16, 2018 at 18:57
  • I very much appreciate this link, not sure how or why I missed it but its definitely helpful. Beyond the debate one user suggested access control lists, to set default permissions. I am investigating this as my solution. Thank you.
    – meschael
    Mar 16, 2018 at 20:06


You must log in to answer this question.

Browse other questions tagged .