Since the file base permissions for umask are 666, is it possible to make a file have 750 permissions when created?
Asked
Active
Viewed 952 times
1
-
Of possible interest: How to set default file permissions for all folders/files in a directory?. – marshki Oct 27 '16 at 23:29
-
It depends. What is creating the file? – phemmer Oct 28 '16 at 01:18
-
Please check this. http://unix.stackexchange.com/questions/47178/can-files-be-created-with-permissions-set-on-the-command-line – Trishansh Bhardwaj Oct 28 '16 at 06:14
1 Answers
2
Generally, no. Virtually every program calls open() (or creat() for that matter) with mode 0666, so whatever umask you apply, you'll never get 0750. Even the linker, which creates executables, opens output files with mode 0666 and chmod them later:
strace -f -e file gcc bla.c 2>&1 | fgrep a.out
...
[pid 14096] open("a.out", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3
...
[pid 14096] chmod("a.out", 0755) = 0
If you want different behavior, you need to write your own tools or wrappers around existing tools that perform the intended mode change.
countermode
- 7,533
- 5
- 31
- 58