Score:0

Remove Immutable Flag from /etc/hosts

cn flag

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!

Esther avatar
es flag
check cron and systemd timers for jobs you don't recognize
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.