Operating System - HP-UX
1824976 Members
3875 Online
109678 Solutions
New Discussion юеВ

How can i create files with the following permissions 775

 
SOLVED
Go to solution
Manuales
Super Advisor

How can i create files with the following permissions 775

when my user is logon into the server and when i create a user it is created with the permissions 666, i need they be created as 775
how can i do that? i know i have to user umask command, how do i have to add it into .cshrc profile? i do not need to use "chmod 775" i need they be created in automatical way as 775.

please let me know, thanks.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: How can i create files with the following permissions 775

You cannot from the shell. When a file is created two things are at play: the mode and umask. Umask cannot put back what was never there. The default mode for a regular file is 666; the default mode of directories is 777. Umask can then only "subtract" from these values so that even with the very insecure umask of 000, a regular file is created at most with mode 666. This is intenetional as there is never a need for a data file to have the execute bit set. If you actually need the execute bit set then an explicit chmod is required.

Now, if you are creating these files with C or Perl, it is possible to set the mode with the execute also set but not from the shell.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: How can i create files with the following permissions 775

>Clay: If you are creating these files with C or Perl, it is possible to set the mode with the execute also set but not from the shell.

RIght, typically the only files that need the execute bit set are executables & shlibs. And ld(1) will automatically do that.

The only other case is scripts and since you just about have to have a human involved, he can just use "chmod a+x" after creating them.
If you have a script that creates scripts, you as a human, can add that chmod there.
Peter Nikitka
Honored Contributor

Re: How can i create files with the following permissions 775

Hi,

you can use
umask 002
in the .cshrc to archive write permissions for the group. You'll get a mode of 775 for directories as well.
As the others said: UNIX (and for you think about it: you as well) does not support an automatic setting of the execution bit on plain files normally. You could do it via inheritance ACLs an a directory - but that's another story.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"