1833730 Members
2541 Online
110063 Solutions
New Discussion

change file permission

 
SOLVED
Go to solution
peterchu
Super Advisor

change file permission

I have a directory ( eg. /tmp/temp ) , everyone can write file to it , if I want all the files under this directory are the same owner and permission ( eg. 644 , user1:edp ) , I try to write a script to change the owner and permission but it only change in a minute , I want the file owner and permission will be changed once the file was created ( so that other user can overwrite it ) , could suggest what can I do ? thx
6 REPLIES 6
Naveej.K.A
Honored Contributor
Solution

Re: change file permission

Couldn't really understand what you want to do!!

If the users have the permissions for /tmp/temp directory they can create any file in that directory...

so are you looking for chmod 777 /tmp/temp??

Regards,
Naveej
practice makes a man perfect!!!
Eric Antunes
Honored Contributor

Re: change file permission

Hi,

If you are talking about the same file, all you need to do for users to overwrite it is to give the write permission for all users (if they belong to the same group, you just need to set the "g" permission, not the o"") to this directory:

#cd /tmp
#chmod -R ugo+rxw /temp

Best Regards,

Eric Antunes
Each and every day is a good day to learn.
peterchu
Super Advisor

Re: change file permission

thx replies ,

what I want is to make sure all the file under /tmp/temp are 644 & user1:edp , once any user overwrite/create a file to this directory , it will be changed to 644 & user1:edp .

not the same file , I want ALL the files .

Thx in advance.
Eric Antunes
Honored Contributor

Re: change file permission

Hi peterchu,

I think the better way to do this is just allow the user user1 to write to this /tmp/temp directory.

But you can always allow everyone and schedule a cron job (I don't know any way of doing this at file creation...) executing every 10 minutes, for example, that changes all the /tmp/temp files to user1:edp :

01,11,21,31,41,51 * * * * $HOME/scripts/change_tempfiles_permissions.sh

And change_tempfiles_permissions.sh has:

chown -R user1 /tmp/temp

chgrp -R edp /tmp/temp

Best Regards,

Eric Antunes
Each and every day is a good day to learn.
Darrel Louis
Honored Contributor

Re: change file permission

Hi,

Is this thread related to the one you lauched a week ago:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=872149.?

Files created by a user, will always be the owner of the file.

GL

Darrel
peterchu
Super Advisor

Re: change file permission

thx replies,

Eric's method (cron job) seems only change it in a certain of time , is there method that can change it once it was created.

thx louis , i can't go to the link .