why umask can't set "x" in file creation

Benjamin Franz snowhare at nihongo.org
Wed Jun 22 19:06:28 UTC 2005


On Wed, 22 Jun 2005, jim martin wrote:

> Hi.. why my umask setting can't get the "x" in the file created permission
>
> [root at w2]# umask 0022
> [root at w2]# touch xxx
> [root at w2]# ls -l
> total 20
> -rw-r--r--  1 root root    0 Jun 23 02:32 xxx
>
> [root at w2]# umask u=rwx,g=rwx,o=rx
> [root at w2]# touch yy
> [root at w2 ]# ls -l
> total 24
> -rw-r--r--  1 root root    0 Jun 23 02:32 xxx
> -rw-rw-r--  1 root root    0 Jun 23 02:34 yy

You've misinterpreted what umask does. It doesn't 'set' permissions - it 
'masks' them. IOW it _subtracts_ default permissions. If a program doesn't 
_request_ the permission at file creation (touch doesn't request execute 
permission), a permissive umask won't force it be set. If you want execute 
permissions after creating a file with 'touch' you need to 'chmod +x' it 
afterwards.

-- 
Jerry

Simple things should be simple, complex things should be possible.
                                          - Alan Kay




More information about the users mailing list