Since the file base permissions for umask are 666, is it possible to make a file have 750 permissions when created?
- Of possible interest: How to set default file permissions for all folders/files in a directory?.marshki– marshki2016-10-27 23:29:39 +00:00Commented Oct 27, 2016 at 23:29
- It depends. What is creating the file?phemmer– phemmer2016-10-28 01:18:08 +00:00Commented Oct 28, 2016 at 1:18
- Please check this. http://unix.stackexchange.com/questions/47178/can-files-be-created-with-permissions-set-on-the-command-lineTrishansh Bhardwaj– Trishansh Bhardwaj2016-10-28 06:14:15 +00:00Commented Oct 28, 2016 at 6:14
Add a comment |
1 Answer
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.