Operating System - HP-UX
1833446 Members
3211 Online
110052 Solutions
New Discussion

Default file permissions.

 
Gulam Mohiuddin
Regular Advisor

Default file permissions.

When I create any file, it has the following permission by default.
-rw-r--r-- 1 ora64 dba 11 Sep 27 10:17 gulam.txt

But I would like the default permission to be as follows instead:

-rw-rw-rw- 1 ora64 dba 11 Sep 27 10:17 gulam.txt

Please let me know how to get this done.

Thanks,

Gulam.
Everyday Learning.
5 REPLIES 5
Stefan Farrelly
Honored Contributor

Re: Default file permissions.

You need to change your umask. Do;

umask 000
touch tt
ls -l /tmp/tt (it will now be -rw-rw-rw-)
Im from Palmerston North, New Zealand, but somehow ended up in London...
A. Clay Stephenson
Acclaimed Contributor

Re: Default file permissions.

Hi:

I rather like how it works now because your umask is set to 022 - this is the preferred level of security.

To make the change you requested
umask 000 which you can set in your .profile.

The best way is something like this in scripts which create files:

savemask=`umask 0000`
do you stuff here
umask ${savemask}

This sets your umask to 0000 and saves ther original value. When you are finished, it resets umasks back to the safer value.

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

Re: Default file permissions.

Are you sure you want the file to be world writeable? That is very dangerous, especially for a database file.

Anyway, to change the default permissions you need to change your umask to 000.

To do that use the command: umask 000

You can put this in your .profile if you want it to be your default.
Robin Wakefield
Honored Contributor

Re: Default file permissions.

Hi,

Run "umask 000" - put this in your .profile to make it permanent.

Rgds, Robin
James R. Ferguson
Acclaimed Contributor

Re: Default file permissions.

Hi Gulam:

While you can certainly set your umask in your $HOME/.profile to 000 as others have indicated, I would give consideration to using a mask value of 022 or 027 as the default and 'chmod'ing permissions on an individual (script) basis. Your auditors will like you much better, too ;-)

Regards!

...JRF...