title: Change DNS server by editing /etc/resolv.conf file (using sed) and problem
body: <p>I want to change the DNS server for my Linux machine. So, I'm going to edit /etc/resolv.conf file.  </p>
  
  <p>The command I'm using is <strong>SED</strong>. And doing as below for change DNS server to <strong>192.168.1.5</strong>:<br>
  <code>#cat /etc/resolv.conf | sed '/nameserver/ c\ nameserver 192.168.1.5' &gt; /etc/resolv.conf</code></p>
  
  <p>The problem is:</p>
  
  <p>When I execute the command the first time and it changes the resolv.conf to something like:</p>
  
  <p><code>domain somedomain<br>
  namserver 192.168.1.5</code></p>
  
  <p>but when I execute it once again to change DNS server to 192.168.1.4:<br>
  <code>#cat /etc/resolv.conf | sed '/nameserver/ c\ nameserver 192.168.1.4' &gt; /etc/resolv.conf</code></p>
  
  <p><strong>The file resolv.conf becomes empty</strong></p>
  
  <p>Questions:<br>
  1. Am I doing the right way to change DNS server?<br>
  2. Is there problem with the <strong>sed</strong> command in the above command?</p>