Ubuntu: Could not resolve archive.canonical..com


I am new to ubuntu and am trying to do a software install. I am getting this error:

Could not resolve 'archive.canonical..com'  

I've noticed there's an extra . in there. Is there a way to fix this?


For this open a terminal (ctrl+alt+t) and edit the /etc/apt/sources.list file by:

sudo nano /etc/apt/sources.list  

There are actually two lines with canonical in it, check them for the double . and remove one. Then press ctrl+x to stop editing, press y to save and confirm the filename with a press on return.


This sed one liner should fix it:

sed -ri.bak 's/(archive\.canonical\.)\.(com)/\1\2/' /etc/apt/sources.list  

Assuming the repositories are defined in the /etc/apt/sources.list file.

To run it over the .list files in /etc/apt/sources.list.d directories too:

sed -ri.bak 's/(archive\.canonical\.)\.(com)/\1\2/' /etc/apt/sources.list /etc/apt/sources.list.d/*.list  

The original file will be kept with a .bak extension.

If you do not want to keep a backup:

sed -ri 's/(archive\.canonical\.)\.(com)/\1\2/' /etc/apt/sources.list  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »