1834448 Members
2500 Online
110067 Solutions
New Discussion

umaks

 
Indrajit_1
Valued Contributor

umaks

Hi all;
i have a hp box where umask value is set to 027. when i create a file in my home directory, the default permission is set to rw-r--
but, it should be rwx-rx---- which means (777 - 027)
if i create a directory in my home directory, the default permission is rwx-rx----.
Is there any way we can set some parameter so that i have the same default permission for file too.
if for file it is ( 666 - 027 ) which rw-r-----, it should not be right format. Please advice.

Cheers
Indrajit
Never Ever Give Up
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: umaks

Files do NOT get created with the execute permission bit set by default. There are actually very few files that need that bit set. Only execuatable files (scripts, binary programs, etc) need the execute bit set.

So, what you are seeing is absolutely correct.

Unless you write a C program, you cannot control the default permissions.
Geoff Wild
Honored Contributor

Re: umaks

Directories are different - have to be executable - else you won't be able to cd to them.

umask is set in either /etc/profile and/or your own .profile

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
James R. Ferguson
Acclaimed Contributor

Re: umaks

Hi:

This behavior is normal and cannot be changed for files and directories created by the shell.

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: umaks

There are two things at play when files are created in the shell and you only have control over one of them - umask. The first is the mode of the file and the second is umask. Umask "subtracts" from this mode to yield the actual mode of the file. (It's not really subtraction but you can kinda, sorta think of it that way; it's really a bitwise NAND). Umask can't put back what was not there in the first place. The mode of regular files created by the shell is 666 (rw-rw-rw); the mode of directories is 777 (rwxrwxrwx).

In order to set the execute bit on a regular file in the shell, an explicit chmod is required after the file is created.

This can be a one-step operation under C, Perl, etc. but not in the shell.
If it ain't broke, I can fix that.
Indrajit_1
Valued Contributor

Re: umaks

Hello All;

Thanks all of you. i appreciate you help.

Cheers
Indrajit Roy.
Never Ever Give Up