I am attempting to change the /etc/hosts file on a VPS with Ubuntu 20.04 LTS.
I cannot open the file for editing and chmod is not able to affect the file:
root@Montgomery06:~# sudo chmod +w /etc/hosts
chmod: changing permissions of '/etc/hosts': Operation not permitted
I tracked the issue to the immutable flag on the /etc/hosts file. But even after running the chattr command, the immutable attribute either remains or inexplicably returns after a few seconds.
root@Montgomery06:~# lsattr /etc/hosts
----i---------e----- /etc/hosts
root@Montgomery06:~# chattr -i /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
----i---------e----- /etc/hosts
root@Montgomery06:~#
root@Montgomery06:~# chattr -i /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
--------------e----- /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
----i---------e----- /etc/hosts
root@Montgomery06:~# chattr -i /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
----i---------e----- /etc/hosts
root@Montgomery06:~#
root@Montgomery06:~# chattr -i /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
--------------e----- /etc/hosts
root@Montgomery06:~# lsattr /etc/hosts
----i---------e----- /etc/hosts
root@Montgomery06:~#
Kernel:
root@Montgomery06:~# cat /proc/version_signature
Ubuntu 5.4.0-42.46-generic 5.4.44
Is there a process that is re-applying that immutable flag? How do I find out?
Thanks!