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.

I know how to use setgid on directories, to enforce that whole directory structure has uniform user:group ownership.

Is there a similar way to set the umask for a directory, so that the whole directory structure "inherits" specific permissions (i.e. 750/640)?

share|improve this question
2  
No, umasks aren't attached to directories, they're attached to a process. askubuntu.com/questions/44534/…. Setting a ACL (using setfacl) might be a way though. –  slm Jan 28 at 14:34

2 Answers 2

up vote 1 down vote accepted

Here is ugly hack to apply on directory.

mount -o loop,umask=027,uid=test /opt/dev_test /home/test/test2

Since umask on mount point applied on NTFS or VFAT partition, I had created block device using dd command then formatted with mkfs.vfat and mounted with command as mentioned above.

Test Result

Inside test2 directory

[test@test-server test2]$ touch xyz
[test@test-server test2]$ ls -rlt xyz
-rwxr-x--- 1 test root 0 Jan 28 23:22 xyz
[test@test-server test2]$ umask
0002

Outside test2 directory

[test@test-server test2]$ cd ../
[test@test-server ~]$ touch xyz
[test@test-server ~]$ ls -rlt xyz
-rw-rw-r-- 1 test test 0 Jan 28 23:22 xyz
[test@test-server ~]$ umask
0002
share|improve this answer

The umask value for the process that creates a file or a directory will control the ultimate specific permissions at the time the process executes. By convention (default), files are created with a creation mode (to open()) of 0666 while directories are created with 0777. The umask value is then factored in to establish the final permissions.

Thus, your "best" choice is to make sure that processes that manipulate the particular directory use a umask of 0027 while will provide directories with 0750 and files with 0640.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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