Operating System - HP-UX
1823986 Members
4050 Online
109667 Solutions
New Discussion юеВ

How to set umask for rwxrw-r--

 
Ezhilarasan
Occasional Advisor

How to set umask for rwxrw-r--

Hi,

How to set umask for file permission rwxrw-r--
I tried with umask u=rwx g=rw o=r
But I am not getting expected file permission.
I do not know the numeric values setting in umask. Please help on this.

Thanks
R.Ezhil
11 REPLIES 11
John Palmer
Honored Contributor

Re: How to set umask for rwxrw-r--

Hi,

The numeric value is 764.

Regards,
John
T G Manikandan
Honored Contributor

Re: How to set umask for rwxrw-r--

It should be
#umask 013

By default for text files it is 666.so with effective umask
it becomes rw-rw-r

For executables and dir it is 777.So with umask it becomes rwxrw-r--


Thanks
Andreas Voss
Honored Contributor

Re: How to set umask for rwxrw-r--

Hi,

umask 764 gives when mkdir:
d-----x-wx

umask 013 gives when mkdir:
drwxrw-r--

Note the x flag is only affected by directories, NOT by files ie.:
umask 764 and touch file:
--------w-
umask 013 and toch file:
-rw-rw-r--

Regards
CCIL
Frequent Advisor

Re: How to set umask for rwxrw-r--

Hi
use the command umask=021
Amit Vichare
Michael Steele_2
Honored Contributor

Re: How to set umask for rwxrw-r--

Umask is a security command.
Here are default permissions for files and directories:

rw-rw-rw- for files and
rwxrwxrwx for directories.

It works by subtracting not adding permissions, hence, un-masks.

Best suggestion is to add a chmod line after your file creation line, as umask, as a rule, won't do it.

Examples: umask 022 on files:

default file rw-rw-rw-
umask (----w--w-)
renders rw-r--r--


Examples: umask 022 on dirs:

default file rwxrwxrwx
umask (----w--w-)
renders rwxr-xr-x
Support Fatherhood - Stop Family Law
U.SivaKumar_2
Honored Contributor

Re: How to set umask for rwxrw-r--

Hi,

It is not possible with umask.

If umask is set for 022 .

Then the default permissions of a directory created will be ,

777-022=755
(Should subtract umask from 777 )

The default permissions of a file created will be ,

666-022=644
( Should subtract umask from 666)

Therefore there exists no umask value for file permission which would fit in to your requirement.

regards,

U.SivaKumar


Innovations are made when conventions are broken
John Palmer
Honored Contributor

Re: How to set umask for rwxrw-r--

Apologies, I misread your question and gave you the numeric value for chmod to give rwxrw-r--.

You can't achieve rwxrw-r-- with umask as the 'x' permission is omitted when creating files. The nearest is 012 which results in rw-rw-r--.

Regards,
John
Joshua Scott
Honored Contributor

Re: How to set umask for rwxrw-r--

To set file permissions, use 'chmod'

you should type :

chmod u=rwx,g=rw,o=r

HTH!
What are the chances...
Gary Yu
Super Advisor

Re: How to set umask for rwxrw-r--

Hi,

As I understand, the files permission when created is determined by default file creation mask which is 666 against your current umask, which means you can NOT create a file with u=rwx what's so ever, you must use chmod to set it.

Gary
A. Clay Stephenson
Acclaimed Contributor

Re: How to set umask for rwxrw-r--

This must be a two step process - unless this is a direcory. The creation mode for directories is 777 and then umask subtracts from that; for regular files the creation mode is 666 and again umask subtracts from that. (Actually all the bits in umask are negated and then AND'ed with the creation mode but it LOOKS like subtraction.) If this is a regular file and you want to set the execution bit that must be a separate step using the chmod command.
If it ain't broke, I can fix that.
Shannon Petry
Honored Contributor

Re: How to set umask for rwxrw-r--

Yes, setting an executable bit on file creation is not possible. Normally this is done by compilers and specialized programs.

The best you can do is 664 permissions for files (umask 002). This would give directories rwxrwxr-x, and files rw-rw-r--.


Very old unix gave the executable bit, but quite honestly I have not seen this done by the OS since Solaris 1.9(I think).


Regards,
Shannon
Microsoft. When do you want a virus today?