Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How to set default file permissions for all folders/files in a directory?

Say I have default umask, umask1. I would like all files/folders that I create/modify under a specific path

/path/to/foo

to have a different umask, umask2, and keep using umask1 for everything else. Is there a way to have the shell do this automatically for me? If so, how?

Is there a way to do this for everyone else who belongs to the groupID of /path/to/foo?

share|improve this question
add comment

marked as duplicate by Mikel, jw013, jasonwryan, Renan, warl0ck Dec 1 '12 at 2:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 2 down vote accepted

You need to use default ACLs.

Note that the syntax is a bit different, and is based on the positive permissions, not the negative permissions mask, e.g. rwxr-x--- would be 750 rather than 027.

For example

setfacl -m d:u::7,g::5,o:0 /path/to/foo

or

setfacl -m d:u::rwx,g::r-x,o:- /path/to/foo

will make it so that files and directories created under /path/to/foo are 750 = rwxr-x--- by default.

If you already have some subfolders, you'll want to add the -R flag to set their defaults recursively as well.

If you get an Operation not supported error, you probably don't have ACLs enabled on your file system. The correct answer depends on many things, but if you're on Linux using ext2/ext3/ext4, try

sudo mount -o remount,acl <mount point>

or

sudo tune2fs -o acl <file system>

See also How to set default file permissions for all folders/files in a directory?

share|improve this answer
    
When I run setfacl -d -m g::rwx /path/to/foo I get Operation not supported (?) –  user815423426 Nov 30 '12 at 16:51
add comment

You can mount the directory with specific permissions and effective umask using bindfs. See http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html.

share|improve this answer
add comment

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