1827136 Members
3035 Online
109716 Solutions
New Discussion

Re: How to set umask

 
Abel Berger
Regular Advisor

How to set umask

Hello everybody !

How can I set umask in my .profile for the file mode creation either 777 ( rwxrwxrwx ) ?

Regards,

Abel Berger
11 REPLIES 11
Abel Berger
Regular Advisor

Re: How to set umask

I tryed put in my .profile :

umask a+rwx but I not have a succeful.

Why ?
Any idea ?

Regards

Abel Berger
A. Clay Stephenson
Acclaimed Contributor

Re: How to set umask

Hi abel,

You are thinking backwards. Set your umask in .profile like 'umask 000'; this will not mask off any bits. BTW - 000 is a dangerous umask are you sure you want everyone to be able to access your files?

A more typical would be 022 (only I can cwrite to my files) or 002 (only I or members of mt group can write to my files).

Clay
If it ain't broke, I can fix that.
Wieslaw Krajewski
Honored Contributor

Re: How to set umask

Hi,

Max what you can obtain are permissions:

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

But this is not recommended from the security reasons.
Recommended umas is 022 or 002. The first results in
rw-r--r-- for files and rwxr-xr-x for directories whereas
the second results in rw-rw-r-- for files and rwxrwxr-x for directories.

Rgds.
Permanent training makes master
Abel Berger
Regular Advisor

Re: How to set umask

Hi Clay,

In this box I don?t have root acess but a
script create files that later I need execute
they, but in .profile umask is set 0022, then
the files was created rw-rw-rw. Of course I
can rack every .profile on this box but I changed umasks and created a arquivo, for example, touch test, and it appear as below :
-rw-rw-rw , I can?t change for umask for arquive will create with rwxrwxrwx, What is
happen ?
Could you help me ??
Thanks.

Abel
Abel Berger
Regular Advisor

Re: How to set umask

Imagine a any user ( final user ),
I need that every files for him created
stay rwxrwxrwx , JUST for this user.

I hope this helps.

Abel
A. Clay Stephenson
Acclaimed Contributor

Re: How to set umask

Hi Abel,

Your script that creates the files may be setting umask and thus overrideing any umask in .profile. After your script creates the file, you could add a lne to chmod 777 $filename.

Regards, Clay
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: How to set umask

Your script can set the umask to 0 then create the files and directories, then change back to a sane value such as umask 022. A better technique is to create the file/directory, then use chmod and chown as needed.

It is important to note that rwxrwxrwx or rw-rw-rw- permissions are very harmful to the content of files and directories. Anyone can destroy or corrupt the contents of these files or directories. If these files/directories must be shared, strongly consider the use of group permissions to reduce the risk of data corruption.


Bill Hassell, sysadmin
Abel Berger
Regular Advisor

Re: How to set umask

Hi,

I need execute files created this way :
rw-rw-rw ( umask 0022 ).
It is impossible. First I need change the permissions but I don?t have.
Second way I would can change the umask,
but how ? how ?

Regards

Abel Berger
Joe Colucci_1
Frequent Advisor

Re: How to set umask

Abel,

I don't quite understand what it is you are trying to do, but I STRONGLY recommend you heed the warnings about the umask and file permissions contained in the other posts.

Having said that, the umask is set in /etc/profile. That umask can then be overridden by setting it again in the user's .profile. Finally, you can override that at the command line using the umask command (though it will only be changed for that process).

For CDE logins, /etc/profile are NOT read by default. There are instructions in the comments of both files for making them CDE safe. After making the changes contained in the comments, you can read them during a CDE login.

To read .profile during a CDE login, include the line DTSOURCEPROFILE=true in the user's .dtprofile.

To read /etc/profile during a CDE login, make a link to /etc/profile in /etc/dt/config/Xsession.d.

Sourcing .profile and /etc/profile during CDE logins can be desirable so that users have the same environment regardless of how they login.

It is a MUCH better idea to create the file and use chmod rather than mess with the umask.

--Joe
Joe Colucci_1
Frequent Advisor

Re: How to set umask

What I meant to say is that /etc/profile and .profile are NOT read by default during a CDE login.
Paula J Frazer-Campbell
Honored Contributor

Re: How to set umask

Abel

Fija por favor su pregunta en espa?ol o portugu?s pues estamos teniendo problemas en intentar entender lo que usted tring para alcanzar.
Si usted va:- http://babelfish.altavista.com/translate.dyn all? es un servicio de traducci?n.

Paula

Abel
Afixam por favor sua pergunta em espanhol ou os portugu?ses porque n?s estamos tendo problemas em tentar compreender o que voc? tring para conseguir.
Se voc? for:- http://babelfish.altavista.com/translate.dyn l? ? um servi?o de tradu??o.

Paula

Abel
Please post your question in spanish or portuguese as we are having problems in trying to understand what you are tring to achieve.

If you go to :- http://babelfish.altavista.com/translate.dyn there is a translation service.

Paula
If you can spell SysAdmin then you is one - anon