新装了一台Ubuntu的虚拟机,在使用apt-get update命令时,失败;其实不只是这个命令,安装其他软件是也会出现错误,无法连接到网络资源。
当运行apt-get update后出现如下错误时:
Some index files failed to download, they have been ignored, or old ones used instead.
解决方案:
- sudo nano /etc/resolv.conf
- 在其中加入:
nameserver 8.8.8.8
- 重启网络: sudo /etc/init.d/networking restart
重新执行apt-get update 成功!
有可能还需要执行:
sudo rm -r /var/lib/apt/lists/
参考:
https://www.yuque.com/docs/share/104158f5-3d30-40ab-8fea-efefe3144aff