1753626 Members
5593 Online
108797 Solutions
New Discussion юеВ

umask in HP-UX

 
Bala_4
Occasional Advisor

umask in HP-UX

Hi All

I have umask 022 set in my .profile file. when I create a directory, the file permission is drwxr-xr-x, which is correct. Now under this directory, I create a file, the file permission is -rw-r--r-- instead of -rwxr-xr-x. I donot want to use chmod command everytime.
1) How do I get -rwxr-xr-x on a file ?
2) I am also looking for file persmission -rwx------.

Can any one help me for setting the above two file permissions. I read the man pages, but still couldnot resolve the issue.

Thanks in advance

Bala
5 REPLIES 5
Kevin Wright
Honored Contributor

Re: umask in HP-UX

the default permission for files are
rw-rw-rw..therefore with a umask of 022, you get rw-r--r--.
the default permission for dir is rwxrwxrwx, so you get rwxr-xr-x.
with the default permissions the way they are, it is impossible to get x on a file. perhaps there is a kernel parameter that can change this?
James R. Ferguson
Acclaimed Contributor

Re: umask in HP-UX

Hi Bala:

The key is that the default permissions for files at creation are 666 (-rw-rw-rw-) whereas for directories the default is 777 (rwxrwxrwx).

Thus, using a umask of 022 gives:

-> files: 666 - 022 = 644 (-rw-r--r--)

-> directories" 777 - 022 = 755 (rwx-r-x-r-x)

Thus, for files, setting umask to 077 will yield a file with permissions of -rw------ for which you will have to use 'chmod' to make it executable.

...JRF...
...JRF...
Vincenzo Restuccia
Honored Contributor

Re: umask in HP-UX

$ umask 022
If this line was in your .profile, it would set your process umask value to 022, which means a file created later will be 644 (rw-r--r--) rather than 666 (rw-rw-rw-), or 755 (rwxr-xr-x) instead of 777 (rwxrwxrwx).
Bill Hassell
Honored Contributor

Re: umask in HP-UX

From a user point of view, setting the execute bit might be useful for a script writer but of no value for a documentation writer. Years ago, the Unix gods decided that executable files are the exception (and they certainly are in places like /etc) rather than the rule. To set the execute bit, you can use chmod +x to add the bits, or just use chmod 755 when needed.


Bill Hassell, sysadmin
Dan Bonham
Advisor

Re: umask in HP-UX

Hello,
In the past, I've created useful aliases for creating files, especially scripts. you could set up and alias that does a touch then chmod... or write a little script to do the same thing. You could also have it "vi" the file so all you have to do is type in the script name and pass it the new file name and it does all three steps for you.

HTH

Rusty Sapper