1827802 Members
2362 Online
109969 Solutions
New Discussion

Re: file mode

 
SOLVED
Go to solution
juno2
Super Advisor

file mode

The default mode of user create file is 644 , can force the file mode must be 666 when the user write the file to the directory /tmp (except run a crontab job to change it)?
7 REPLIES 7
Pete Randall
Outstanding Contributor
Solution

Re: file mode

Set the user's umask - see man umask.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: file mode

Oh, you mean only for /tmp? I can't think of a way other than the cron job you mentioned!


Pete


Pete
juno2
Super Advisor

Re: file mode

thx reply,

but if i change umask , all file mode will be changed , except use cron job , is there other method ? thx.
Bill Hassell
Honored Contributor

Re: file mode

There is no simple way to accomplish this task since changing (or specifying) a specific directory has no link to umask. Users will simply have to be better educated or remove their shell prompt and give them a menu of tasks that they are allowed to perform and set umask as required as part of the menu program.

Another alternative is to set umask to 072 for certain users and put these users into a special group so group permissions will be effective but not give away everything. 666 is a very nad permission for anything except a junk file because that is all you can expect. 666 files (or the more common 777) means that the contents may be trashed by any user on the system.


Bill Hassell, sysadmin
Karthik S S
Honored Contributor

Re: file mode

Hi,

I was just wondering if a trap can be set when the use does a cd to /tmp and is there any way by using a trap can we change the umask??

-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Massimo Bianchi
Honored Contributor

Re: file mode

Hi,
just a warning. Many application stores they temporary files in /tmp.
If you are going to create a cron job that will change recursively all the permission to files in /tmp, take care that some apps may stop working or behave strangely.

HTH,
Massimo
Bill Hassell
Honored Contributor

Re: file mode

Although you could put an alias in the user's profile so that cd is now a script, a good Unix user will often never cd into a directory just to look for or create files. Instead, a full pathname is used such as:

vi /tmp/xyz

There are just too many ways to create a file in a specific directory.


Bill Hassell, sysadmin