Reputation: 400
I've installed a CMS on my CentOS which changes a file constantly. And I want to prevent it from being changed. I tried:
chattr +i file.php
Or:
chmod 444 file.php
Even I've tried copying file(as file.php2) and then mounting it:
mount --bind file.php2 file.php -o ro
Then how can I prevent my file from being changed by that CMS?
Upvotes: 0
Views: 961
Reputation: 226
Try sudo chmod 400 file.php
This will make the file non editable to other users.
Upvotes: 1
Reputation: 88
You must
chmod 644 file.php
chown root:root file.php
chmod 755 /path/to/dir/containing/
chown root:root /path/to/dir/containing/
Why work on the folder too ?
Because a user having write rights on a folder can delete any other user's files, even if he couldn't write to it or read it. As a consequence, if you do not change the folder's permission too, the CMS user could delete your 'protected' file and write another one in its place.
Edit: and of course, your CMS shouldn't run as root, or all the above would be ignored
Upvotes: 1