1

Since the file base permissions for umask are 666, is it possible to make a file have 750 permissions when created?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

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