Issue
I ran the following commands:
chown root:root file.php
chmod 0644 file.php
Settings appear to have been applied when typing ls -l
:
-rw-r--r-- 1 root root 310 Jul 26 01:25 file.php
However, the original user can still edit the file via Cpanel File Manager and upon saving, the file ownership went back to the original user. E.g.,
-rw-r--r-- 1 orig_user orig_user 310 Jul 26 01:25 file.php
How do I prevent the user from editing files already owned by root?
Solution
Use chattr
on the file to make it immutable.
sudo chattr +i file.php
Answered By - merlin2011 Answer Checked By - Mildred Charles (WPSolving Admin)