Add the loopback entry to the first line in the /etc/hosts file
I need to create a module which checks if the /etc/hosts file has the first line with the loopback entry.
If it does, do nothing; else, insert
127.0.0.1 localhost localhost.localdomain
in the first line of the file right after the comments.
I tried using augeas but even if I write something using node(0), it doesn't let me save that file. I tried with augtool using the Hosts lens. Can someone please help me if this is possible or not.