1828348 Members
3175 Online
109976 Solutions
New Discussion

Re: File mode

 
SOLVED
Go to solution
peterchu
Super Advisor

File mode

I have a file on the system , many users can access and update it , how can I fix the file mode ( eg. 666 ) , to prevent the user change the mode ? thx.
3 REPLIES 3
Elmar P. Kolkman
Honored Contributor
Solution

Re: File mode

This can be done by closing the directory for writing... Just do: 'chmod go-w .' while in the directory. This means they can't create files too, btw.

Another way: set the 'sticky' bit on the directory: 'chmod o+s .' This has some other side effects (users can't remove files not owned by them.

Test to see what's best for your situation.
Every problem has at least one solution. Only some solutions are harder to find.
K.C. Chan
Trusted Contributor

Re: File mode

just make sure the file is not own by any users which you do not want to have ownership; maybe you want to own the file. AFAIK, you can only change mod if you own the file (besides all mighty powerfull root, offcourse).
Reputation of a thousand years can be determined by the conduct of an hour
Martin P.J. Zinser
Honored Contributor

Re: File mode

Hello Peter,

exactly which mode to set really depends on how this file is supposed to be used. Do all users on the system need rw to the fil? In that case 666 is the right protection. Do only users of one group need access? Chmod 660 would do that.
Ist is it a few users from different groups, add a new group, add the members to it, make the file owned by the group and again go 660. Users might need to do a chgrp to the right group in this case to gain access. If you need finegrained access have a look at ACLs.

Greetings, Martin