ubuntu 执行apt-get update报错Failed to fetch_error: failed to solve: process "/bin/sh -c apt-ge-程序员宅基地

技术标签:   ubuntu  服务器配置  

在ubuntu下执行sudo apt-get update时,经常会遇到报错:

Err http://security.ubuntu.com precise-security InRelease

Err http://security.ubuntu.com precise-security Release.gpg
  Temporary failure resolving 'security.ubuntu.com'
Err http://cn.archive.ubuntu.com precise InRelease

Err http://cn.archive.ubuntu.com precise-updates InRelease

Err http://cn.archive.ubuntu.com precise-backports InRelease

Err http://cn.archive.ubuntu.com precise Release.gpg
  Temporary failure resolving 'cn.archive.ubuntu.com'
Err http://cn.archive.ubuntu.com precise-updates Release.gpg
  Temporary failure resolving 'cn.archive.ubuntu.com'
Err http://cn.archive.ubuntu.com precise-backports Release.gpg
  Temporary failure resolving 'cn.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease  

W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease  

W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease  

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease  

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg  Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg  Temporary failure resolving 'cn.archive.ubuntu.com'

W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg  Temporary failure resolving 'cn.archive.ubuntu.com'

W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg  Temporary failure resolving 'cn.archive.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.

一般都会推荐使用国内的镜像源,比如163或者阿里云的镜像服务器
将下列文本添加到/etc/apt/sources.list文件里

deb http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse  

但是执行sudo apt-get update仍然报错,问题在于DNS没有配置好。
解决方法:

sudo vi /etc/resolv.conf

添加

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
#这里用的是阿里云的DNS服务器
nameserver 223.5.5.5  
nameserver 223.6.6.6

之后执行sudo apt-get update就正常了。

参考:
ubuntu apt-get update 失败解决。
Ubuntu操作系统“Failed to fetch”错误的解决方法
docker ubuntu容器更换阿里源

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/feiniao8651/article/details/60332535

智能推荐

java怎么调用其他包里的类_java怎么调用另一个包中的类-程序员宅基地

文章浏览阅读5.2k次。比如现在有以下两个包:现在想在Boss类里面实现对Employee的调用,怎么做呢?(视频教程推荐:java视频)Employee.java:package payroll2;public class Employee {public void move(){System.out.print("this is employee");}}如果想实现对包的调用,可使用import关键字,然后再用调用类..._java调用其他包的静态类

Linux相关知识-程序员宅基地

文章浏览阅读76次。运行级别 0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行运行级别 1:单用户工作状态,root权限,用于系统维护,找回丢失root密码,禁止远程登陆运行级别 2:多用户状态没有网络服务(没有NFS)运行级别 3:多用户状态有网络服务(有NFS),登陆后进入控制台命令行模式运行级别 4:系统未使用保留给用户运行级别 5:图形界面运行级别 6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动常用运行级别是3和5,工作中一般用3,也可以指定默认运行级别。_linux相关

使用S32DS集成S32K的MCAL_s32ds教程-程序员宅基地

文章浏览阅读4.7k次,点赞9次,收藏67次。一、软件准备前往恩智浦官网下载MCAL软件包、EB Tresos 、以及S32DS IDE:以下软件均有NXP免费提供,但需注册账号获取S32DS IDE下载EB Tresos以及MCAL下载S32DS版本为:S32 Design Studio 3.2其中EB Tresos版本为:24.0MCAL版本为:S32K14X_MCAL4_2_RTM_1_0_0​NXP MCAL软件包后缀说明:HF为补丁版本 RTMC为发布版本软件安装请参考:NXP_AUT.._s32ds教程

欧拉法、改进的欧拉法、龙格-库塔法求解初值问题_欧拉法计算初值问题csdn-程序员宅基地

文章浏览阅读1.9w次,点赞37次,收藏202次。求解初值问题简介前期准备欧拉法改进的欧拉法龙格-库塔法三级三阶显式Kutta公式三级四阶显式Heun公式四级四阶显式Kutta公式四级四阶显式Gill公式简介通过求解简单的初值问题:{dudx=f(x,u)(1)u(x0)=u0(2)\begin{cases}\dfrac{du}{dx}=f(x,u)&&&&&&(1)\\u(x_0)=u..._欧拉法计算初值问题csdn

Git取消add 、 commit、push的命令_git 取消add-程序员宅基地

文章浏览阅读2w次,点赞284次,收藏328次。撤销已经add,但是没有commit的问题git reset HEAD撤销已经commit,但是没有push到远端的文件(仅撤销commit 保留add操作)git reset --soft HEAD^查看状态查看没有git add的文件git checkout 查看当前提交状态git status......_git 取消add

微机原理知识点汇总-程序员宅基地

文章浏览阅读4.3k次,点赞10次,收藏113次。西南交通大学电气学院电子信息工程专业课----微机原理知识点总结,含部分习题。讨论基于8086/8088的CPU及系统结构,汇编语言基础编程_微机原理

随便推点

Ubuntu18.04中LXC安装配置以及简单使用_lxc-create 离线文件ubuntu-程序员宅基地

文章浏览阅读1.2k次。LXC的安装配置以及简单使用_lxc-create 离线文件ubuntu

Springboot——mybatis配置_springboot配置mybatis-程序员宅基地

文章浏览阅读7.5k次,点赞2次,收藏2次。serverTimezone=Asia/Shanghai:可以实现北京时间入库。_springboot配置mybatis

计算机网络体系结构-程序员宅基地

文章浏览阅读825次,点赞27次,收藏18次。计算机网络分层结构,计算机网络协议、接口、服务的概念

韶音、南卡、Oladance开放式耳机值得买吗?多维度测评实力最强品牌-程序员宅基地

文章浏览阅读846次,点赞18次,收藏12次。作为一名热爱音乐的资深用户,我体验过众多品牌的开放式耳机,希望通过我的评测,能够帮助大家找到最适合自己的耳机。不过,在中高频方面,耳机的表现略显刺耳,音质和音量可能不尽如人意,这可能会对用户的整体听觉体验产生一定影响。不过,延迟性相对较高,对于需要实时音视频同步的场景,如追剧或游戏,可能不太适合,存在明显的延迟问题。然而,在使用这项技术的耳机时,尤其是在游戏过程中,可能会遇到较高的延迟问题,这可能导致音画不同步的现象更加明显。然而,在剧烈运动时,耳机的稳固性可能需要加强,以避免因动作过大而导致脱落。

bert简介_tensorflow 2.0+ 基于BERT的多标签文本分类-程序员宅基地

文章浏览阅读3.8k次,点赞6次,收藏24次。在多标签分类的问题中,模型的训练集由实例组成,每个实例可以被分配多个类别,表示为一组目标标签,最终任务是准确预测测试数据的标签集。例如:文本可以同时涉及宗教、政治、金融或教育,也可以不属于其中任何一个。电影按其抽象内容可分为动作片、喜剧片和浪漫片。电影有可能属于多种类型,比如周星驰的《大话西游》,同时属于浪漫片与喜剧片。多标签和多分类有什么区别?在多分类中,每个样本被分配到一个且只有一个标签:水果..._tensorflow bert

jupyter notebook常用快捷键和语法_jupyter notebook怎么换行-程序员宅基地

文章浏览阅读6.1k次,点赞4次,收藏29次。jupyter notebook 常用快捷键及编辑语法jupyter 单元格有两种模式:命令模式(蓝色标签)和编辑模式(绿色标签)。点击单元格外可进入命令模式,点击单元格内进入编辑模式。编辑模式又分为code模式(单元格外有 ‘In [ ]’)即写代码模式和markdown模式(无‘In [ ]’)即写文档模式。一、快捷键根据jupyter单元格所处模式不同,快捷键可分为两类:具体可在jupyter文件编辑界面的‘HELP’选项中查看,这里列出本人认为较为常用的几个。命令模式下的快捷键:_jupyter notebook怎么换行