• 【ubuntu】更换下载源


    ubuntu,我们在使用apt新装软件的时候,会使用官方的网站去下载软件,但是会因为国内的转接点太多,而导致下载的速度非常慢 ,我们可以通过换成一些中间的节点来进行下载,比如阿里源,中科大源,清华源等等,这样的网站,他们会定时和官方的源进行同步和更新,而我们直接同步他们,速度就会比直接同步官方的源快很多,这样能够大大增加我们的下载软件的速度。

    一、ubuntu系统更换源

    文件存放在apt文件夹内

    所以先进入文件夹

    cd /etc/apt
    

    在修改之前对文件进行备份

    sudo cp sources.list sources.list.bak

    对文件进行修改

    sudo vi sources.list

    二、删除掉sources.list的其他内容,任意选择一种源的内容复制粘贴进去,保存,例如,选择阿里源

    2.1阿里源

    deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
    deb http://archive.canonical.com/ubuntu xenial partner
    deb-src http://archive.canonical.com/ubuntu xenial partner
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
    

    今天在用apt-get update更新时一直失败,报的错误为”Failed to fetch 404 Not Found”,因为我的镜像改为了mirrors.aliyun.com 我试着ping了一下发现能通,所以就在网上查找了下答案

    大部分的解释是因为每个Ubuntu版本都有生命结束周期(EOL)时间;常规的Ubuntu发行版提供18个月的支持,而LTS(长期支持)版本则长达3年(服务器版本)和5年(桌面版本)。当某个Ubuntu版本达到生命结束周期时,其仓库就不能再访问了,你也不能再从Canonical获取任何维护更新和安全补丁。在撰写本文时,Ubuntu 13.04(急切的浣熊)已经达到了它的生命结束周期。

    如果你所使用的Ubuntu系统已经被结束生命周期,你就会从apt-get或aptitude得到以下404错误,因为它的仓库已经被遗弃了。

    解决方法为讲/etc/apt/sources.list路径下的源替换为旧版本仓库的源。

    BUT,我的镜像是阿里云的镜像,貌似没有什么旧版本的路径,我就在/etc/apt/sources.list路径下删除,重新替换为下面的路径

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

     之后再apt-get就可以了 

    2.2东北大学源

    deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted
    
    deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted
    
    deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial universe
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
    
    deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted
    
    deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe
    
    deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse
    

    2.3清华大学源

    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
    
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse
    

     

    三、更新下载源

    sudo apt-get update

     四、输入过程中可能会出现的问题

    root@ubuntu:/etc/apt# apt-get update
    Err:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
    Temporary failure resolving 'mirrors.aliyun.com'
    Err:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
    Temporary failure resolving 'mirrors.aliyun.com'
    Err:3 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
    Temporary failure resolving 'mirrors.aliyun.com'
    Err:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
    Temporary failure resolving 'mirrors.aliyun.com'
    Err:5 http://archive.canonical.com/ubuntu xenial InRelease
    Temporary failure resolving 'archive.canonical.com'
    Err:6 http://archive.ubuntu.com/ubuntu xenial InRelease
    Temporary failure resolving 'archive.ubuntu.com'
    Reading package lists... Done

    E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/perl/perl-base_5.22.1-9ubuntu0.5_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules-5.22_5.22.1-9ubuntu0.5_all.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/d/db5.3/libdb5.3_5.3.28-11ubuntu0.1_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g_1.2.8.dfsg-2ubuntu4.1_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/i/init-system-helpers/init-system-helpers_1.29ubuntu4_all.deb Temporary failure resolving 'us.archive.ubuntu.com'

    E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/i/init-system-helpers/init_1.29ubuntu4_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

    vim /etc/resolv.conf
    
    nameserver 127.0.1.1
    nameserver 192.168.23.1  
    nameserver 221.130.33.52  
    nameserver 169.95.1.1  
    nameserver 114.114.114.114 

        在Ubuntu操作系统中,使用apt-get命令安装所需的开发软件非常方便,但也有不少时候由于链接不上软件源而不能正常安装,于是很多人都会想到使用sudo apt-get update命令来更新软件源,而恰恰这时屋漏偏逢连夜雨,更新命令也不能正常工作,出现大量“Failed to fetch”的错误,出现failed to fetch一般来说是要去更新我们的DNS 再次执行 更新操作

    sudo apt-get clean
    sudo apt-get update
    sudo apt-get upgrade

     其他一些命令

    sudo apt-get update  更新源
    sudo apt-get install package 安装包
    sudo apt-get remove package 删除包
    sudo apt-cache search package 搜索软件包
    sudo apt-cache show package  获取包的相关信息,如说明、大小、版本等
    sudo apt-get install package --reinstall  重新安装包
    sudo apt-get -f install  修复安装
    sudo apt-get remove package --purge 删除包,包括配置文件等
    sudo apt-get build-dep package 安装相关的编译环境
    sudo apt-get upgrade 更新已安装的包
    sudo apt-get dist-upgrade 升级系统
    sudo apt-cache depends package 了解使用该包依赖那些包
    sudo apt-cache rdepends package 查看该包被哪些包依赖
    sudo apt-get source package  下载该包的源代码
    sudo apt-get clean && sudo apt-get autoclean 清理无用的包
    sudo apt-get check 检查是否有损坏的依赖
    

      

     

  • 相关阅读:
    css浏览器兼容问题集锦
    【转】H264编码原理以及I帧B帧P帧
    Makefile Shell 脚本;sed命令
    oProfile 学习
    C++ 局部变量的析构
    【转】C++ 单例模式
    C++ operator 知识点 2
    C++ operator 知识点
    218多校第九场 HDU 6424 (数学)
    2018多校第九场 HDU 6416 (DP+前缀和优化)
  • 原文地址:https://www.cnblogs.com/chenxiaomeng/p/9474830.html
Copyright © 2020-2023  润新知