/etc/resolv.conf is open as read-only and cannot edit in Linux

/etc/resolv.conf not able to edit in Linux as the Root user

Error: Try to open the /etc/resolv.conf file from the root user but it’s open as read only file.


  1. Check the attribute of /etc/resolv.conf file
[root@rac1 grd]$ lsattr /etc/resolv.conf
----ia------------ /etc/resolv.conf

2. Change or remove this Ia attribute from /etc/resolv.conf

[root@rac1 grd]$ chattr -a /etc/resolv.conf
[root@rac1 grd]$ chattr -i /etc/resolv.conf

3. Check again with /etc/resolv.conf file

[root@rac1 grd]$ lsattr /etc/resolv.conf
------------------ /etc/resolv.conf

4. Now try to open with vi or gedit editor will fix the read-only issue.

[root@rac1 grd]$ vi /etc/resolv.conf