I am using Ubuntu 14.04 and I have to edit the resolv.conf file

So this is what I am trying to do

sudo su

vi /etc/resolv.conf

But when I try to edit it says the file is read only

When I try to do chmod +w /etc/resolv.conf it gives the error Operation not permitted

How to edit it. I have to edit as this laptop was given to me by company and they configured the nameserver but when I try to use it at home then my wifi though connected but I am not able to use Internet.

If I ping it is working

  • By the way, there's never any reason to run sudo su. If you have activated the root account, use su alone and if not, use sudo -i to get a root shell. sudo su is pointless.
    – terdon
    Apr 3, 2015 at 13:42

6 Answers 6


Stumbled on this problem on CentOS8.

The file may be marked immutable:

# lsattr /etc/resolv.conf
----i--------------- /etc/resolv.conf

Remove the immutable flag as follows:

# sudo chattr -i /etc/resolv.conf
# lsattr /etc/resolv.conf
-------------------- /etc/resolv.conf

Source: https://forums.centos.org/viewtopic.php?t=73182#p307891


The proper way to edit resolv.conf if to add nameserver xxx.xx.xxx.xxx lines to either base, head, or tail files in /etc/resolvconf/resolv.conf.d . They belong to root, but you can edit them with sudo ( or gksu if you prefer graphical text editors ).

Although you ask for editing resolv.conf, there's another way to sent dns in ubuntu that doesn't involve resolv.conf. Look at the line 18 of my /etc/dhcp/dhclient.conf file. Line 19 is also a practical way to do it.

1   # Configuration file for /sbin/dhclient, which is included in Debian's
     2  #   dhcp3-client package.
     3  #
     4  # This is a sample configuration file for dhclient. See dhclient.conf's
     5  #   man page for more information about the syntax of this file
     6  #   and a more comprehensive list of the parameters understood by
     7  #   dhclient.
     8  #
     9  # Normally, if the DHCP server provides reasonable information and does
    10  #   not leave anything out (like the domain name, for example), then
    11  #   few changes must be made to this file, if any.
    12  #

    13  option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

    14  #send host-name "andare.fugue.com";
    15  send host-name = gethostname();
    16  #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
    17  #send dhcp-lease-time 3600;
    18  supersede domain-name-servers,,;
    19  # prepend domain-name-servers,;
    20  request subnet-mask, broadcast-address, time-offset, routers,
    21      domain-name, domain-name-servers, domain-search, host-name,
    22      dhcp6.name-servers, dhcp6.domain-search,
    23      netbios-name-servers, netbios-scope, interface-mtu,
    24      rfc3442-classless-static-routes, ntp-servers,

This sets my dns and lets me browse webs (and nnm-tool command confirms all three dns are used) no matter what i write in my resolv.conf. So try this

  • The OP is already using sudo su, then vi to edit the file.
    – slhck
    Apr 3, 2015 at 8:09
  • He asked what is the proper way of editing /etc/resolv.conf, which is what I answered. Apr 3, 2015 at 8:12
  • I already told that with using sudo also I am not able to change the content it says operation not permitted please help me to edit
    – iec2011007
    Apr 3, 2015 at 8:14
  • Well, in that case you have two separate questions there. Can you edit using sudo any other file ? Apr 3, 2015 at 8:16
  • The nameserver which I want to add "" is present in base but then also I am not able to access internet. Ping og is successful
    – iec2011007
    Apr 3, 2015 at 8:17

If you are using standard Ubuntu then the answer is: Don't edit /etc/resolv.conf but use resolvconf methods to configure what gets written to resolv.conf. There is other documentation and there are other answers in AskUbuntu which cover how to do that.

If you are using a machine that your company has configured other than in standard Ubuntu ways (e.g., so as not to use resolvconf to manage resolv.conf) then you should ask your company IT support department for instructions. Assuming that these instructions really do involve editing /etc/resolv.conf, you should (1) make sure that /etc/resolv.conf is not a symbolic link or remove the symbolic link if it's there; then do (2) sudo vi /etc/resolv.conf and edit the file.


I guess you are having a red color resolv.conf in /etc/

  • Follow these commands:

    $sudo nano /etc/resolv1.conf

    Add following:

  • Save it and then hit following commands:

    $sudo rm /etc/resolv.conf
    $sudo mv /etc/resolv1.conf /etc/resolv.conf
  • No need of Reboot. Now refresh your webpage. It will work now.

sudo apt-get purge resolvconf

then reboot, then you need to install it again

sudo apt-get install resolvconf

This worked for me


I had this exact same problem, and finally resolved it by allowing the ICMP protocol at our Cisco ASA-5540 edge router.

Turns out that if the protocol is not allowed, pings in AND out, are both blocked. It caused a great deal of trouble for us when using CPAN, as some fetches would fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.