I deleted both the resolvconf folder and the resolv.conf file in /etc by mistake, assuming that resolvconf was causing UCK to fail. Now the application has upgraded, fixing the issue, but it says no file named resolv.conf in /etc.
What it says is correct because I deleted those files. Is there any way to recreate the files or restore from another location?
5 Answers
You could reinstall resolvconf to restore the default configuration:
sudo apt-get install --reinstall resolvconf
Another idea would be remove "resolvconf" and then install:
sudo apt-get remove --purge resolvconf && sudo apt-get install resolvconf
-
4Amplification: to ensure that resolvconf is fully restored you have to purge it and install it again, then reboot. If you don't purge it but only remove it then it won't install the symlink at /etc/resolv.conf on reinstall. If you don't reboot then resolvconf's database will generally be missing nameserver information until you do reboot... or reconfigure (down and up) all active interfaces. – jdthood Oct 28 '12 at 20:19
-
4This broke my internet, and now I can't fetch any packages from the ubuntu repos. – dessalines Mar 30 '16 at 16:54
-
4This also broke internet, uninstalled, reinstall failed, and now I cant update anything. – Chris Oct 07 '17 at 00:00
-
8If you find yourself unable to fetch new packages, ping `us.archive.ubuntu.com` on another computer, grab the straight IP address returned and use that in a `wget` (ie: `wget http://91.189.91.26/ubuntu/pool/main/r/resolvconf/resolvconf_1.78ubuntu4_all.deb`) then install using `dkpg` (ie: `dpkg -i resolvconf_1.78ubuntu4_all.deb`) and reboot. Alternative would be to put the IP in your `/etc/hosts` just to get the update/install to complete. – vandsh Oct 12 '17 at 01:04
-
ln: cannot remove '/etc/resolv.conf': Device or resource busy – 1rq3fea324wre Jul 24 '18 at 21:02
-
@vandsh the link `ubuntu/pool/main/r/resolvconf` is not valid, under `r` is no resolvconf. – Timo Apr 30 '22 at 13:41
-
3When you're dealing with a file that controls whether the computer can resolve domain names, please do not suggest uninstalling something and then reinstalling it when reinstalling it will not work when DNS is broken. – Chai T. Rex Dec 15 '22 at 15:53
If resolvconf -u shows the WARNING that /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf then just backup that resolv.conf and make the symbolic link:
$ cd /etc
$ sudo ln -s /run/resolvconf/resolv.conf
- 910
- 1
- 9
- 8
-
5This should be the accepted answer! How would you reinstall resolvconf when you can't resolve hostnames?! – Evils Apr 05 '16 at 14:00
Try this:
nano /etc/resolv.conf
add:
nameserver 8.8.8.8
nameserver 192.168.x.x
(check your ifconfig output for the correct address)
then
sudo service resolvconf start
sudo systemctl enable resolvconf
- 69,223
- 56
- 216
- 327
- 61
- 1
- 1
-
-
This would only affect things temporarily. The /etc/resolv.conf file would be overwritten since it's managed by the resolvconf package. – TheZeke Nov 04 '20 at 09:28
The accepted answer did not work for me. After reinstalling resolvconf, the system would completely wipe my resolv.conf file after each reboot.
To fix this, I had to reinstall the network-manager and libnss-resolve packages in addition to resolvconf.
Manually add a nameserver to resolve.conf (this is so you can fetch packages from the Ubuntu repos):
-
sudo vi /etc/resolv.conf - Add
nameserver 8.8.8.8to the file.
-
Reinstall the
network-manager,libnss-resolve, andresolvconfpackages:apt install --reinstall resolvconf network-manager libnss-resolve
- 31
- 2
-
1Good answer. If your dns resolution is broken, this gets you back to working, so you can effect other repairs. – Kevin Buchs Feb 09 '23 at 13:51
Have you emptied your trash, if not, you can restore from trash.
- 1,159
- 8
- 18
- 41
-
Thanks for reply.I never used delete alone but shift+delete,so not in trash. – beeju May 09 '12 at 00:41
-
1I see. Try to use a recovery program, i.e foremost. Or try to do what @desgua said. – Svetlana Belkin May 09 '12 at 00:43