I've encountered a very annoying problem recently. I want to share a folder named 'html' to 'users' group with full control over it (rwx), but there is one file in that folder, named 'index.html', that I don't want any user other than root to write to that file (r-x). How can I do that?
After these changes:
$ su root
$ chgrp -R users html/
$ chmod -R 775 html/
$ cd html/
$ chgrp root index.html
any user can write to 'index.html', and even permanently delete it. I don't want it to happen, so how can I secure that only file? Can I even do that? How does this anomaly exists?
If you want to no one can edit it also root user(readonly), you can do this as a root
chattr +i html/index.html
And if you want to revert it(access to write), you must run this
chattr -i html/index.html