Setting permissions based on directory independent of owner

Posted on 2006-03-29
Last Modified: 2013-12-16
Anyone know how to set one set of default file permission on one file/directroy and another set of permissions on another ?

Set A might be:
 - read/write owner, everyone else read

Set B might be:
 - read/write developers, everyone else read

So that if any file/directory is created it will take on the permission of the section rather than the default permissions of the user. This is at the filesystem level and not exposed through Samba or any other mechanism.

Example: A web server is running on a debian box. Developers have local changes in their home directory which they wish to copy to the site served by the web server. When in their own home directory, a developer's files have "Set A" permissions. When a file is copied to the web directory, its permissions should change to those of "Set B".

Ideally this should require no manual altering of permissions, and should be taken care of by the filesystem to reduce the chance of human error by as much as possible. Is there a way to achieve this?

Question by:nwrangham
    LVL 14

    Accepted Solution

    No, there is no way to do this.

    The only control the directory has on the files is the group-ownership (sgid on the directory will set newly created files to the same group as the directory).

    This is because files can live in more than one directory in Unix, unlike just about any other OS.

    Author Comment


    I was worried that would be the case

    Thanks for your help
    LVL 43

    Expert Comment

    Not entirely true.
    Newer kernel has the feature called inotify, where You can plug Your own actions to be taken upon file change/creation.
    Could be that, but I never use it.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now