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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Because files created by default having permission of 666 and umask (in permission bits form) subtract bit-wise from this permission, can we do something to give execute permission without using permission character (r,w,x) ?

I am refering to using bit-wise mask, e.g

umask 002

not setting permission character such as

umask u+x
umask u=rwx
share|improve this question
up vote 5 down vote accepted

This is not possible. umask only prevents permissions but never adds them. Thus you get execute permission only if the creating open() syscall does contain them. This is the case if a compiler creates an executable file.

share|improve this answer

The permission of a new file is computed from the permission used with the creat() call.

You umask results in:

$ umask 002
$ umask -S
u=rwx,g=rwx,o=rx

So if you use creat() with a file permission of 0777, you will get a new file with rwxrwxrx. Usual programs however use 0666as file permission argument for creat().

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.