On my home server is a “public” directory, where my users are able to place common files without eating into their own disk quota. The main problem I encountered in setting this up was that, when different users would write to this directory, the files would retain original ownership so that it still counted against their quotas, and others could not modify or delete them. Unfortunately, Linux does not have a simple way of enforcing recursive ownership/permissions.

Finally, after long months of impotent frustration, I stumbled upon the following trick, though I can’t credit the original author as I don’t remember the source. I installed sys-fs/inotify-tools via Gentoo Portage, which is a tool that uses the kernel’s inotify subsystem to monitor filesystem changes. I then created the following file, tagged it executable, and put it in my startup scripts:



# Watch /path/to/directory for changes
inotifywait -rqm --event CREATE --format %w%f /path/to/directory | while read file; do
    # Check if object in question is a directory
    if [ -d "${file}" ]
            chmod -R 775 "${file}"
            chmod -R 664 "${file}"
chown -R user:group "${file}"


This will recursively monitor /path/to/directory for any files or directories created within, and subsequently apply the specified commands to them as ${file}.

This solution isn’t as clean as I’d like, but it’s functional and stable.