Operating System - HP-UX
1832870 Members
5103 Online
110048 Solutions
New Discussion

default file creation mask

 
Gary Yu
Super Advisor

default file creation mask

Hi all,

To my knowledge, in HPUX, the default file creation mask is "0666",or "rw-rw-rw-", and if you have set umask, then it will apply.

But the problem is, umask is applied against the current creation mask(0666), which means no matter how do you set umask, you can't create a file with 'x' permission by default -- is there any way to change the "0666" default file creation mask? (not globally but on a user basis would be even better).

thanks,
Gary
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: default file creation mask

Hi Gary,

You need to set it in /etc/profile and it is going to affect everyuser. 022 is most generally accepted umask and if you can bargain for 077 from your users, that will be nice.

On per user basis, they will need to keep this entry in their .profile file of the home directory.

There is a rough way of doing it on per user or per group basis. You will need to embed a script in side /etc/profile to set the umask. For ex., if I keep this script in /etc/profile, then it will set the umask for user1 to 077

if [ $LOGNAME = "user1" ]
then
umask 077
else
umask 022
fi

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Wodisch
Honored Contributor

Re: default file creation mask

Hi Gary,

the default "umask" is 002, not 666, of course.
And compilers do create their files with 777 (minus umask, of course).
But what you ask for can be done with the new JFS3.3 filesystem's ACL (Access Control List) features!
Read the man page about "setacl" for the details...

HTH,
Wodisch
Gary Yu
Super Advisor

Re: default file creation mask

thanks guys for the reply.

Yes I know the default umask is not "0666", but the default "creation" mask is "0666"(before umask applied), e.g if you don't have umask set, or set as 000, when you create a new file through vi or touch, the file permission will be 0666(rw-rw-rw-), I'm just wondering how to change that to, say 0766.

Maybe the ACL setting for onlineJFS would solve the problem, but I don't have onlineJFS installed ...
Sridhar Bhaskarla
Honored Contributor

Re: default file creation mask

Gary,

Unfortunately you cannot get "x" permission by default with any umask. So, you have to stick with read and|or write permissions when you "create" a file.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Bill Hassell
Honored Contributor

Re: default file creation mask

According to the man page for umask, file permissions of 666 are and'ed with umask, while directory permissions of 777 are and'ed with umask. An executable file is very special (perhaps not for sysadmins that write a lot of scripts) but historically, Unix looks at files as simple data files which means that adding the X attribute is meaningless. This a classic Unix behavior.


Bill Hassell, sysadmin