Ubuntu18.04更改apt-get的下载源

简介: 前些天搞了个服务器,今天抽时间配置一下,发现使用apt-get安装东西的时候总是会失败,提示需要apt-get update,但是执行后又会报错“W: Some index files failed to download. They have been ignored, or old ones used instead.”,想了想应该是源的问题,于是查了一下Ubuntu更改下载源的方法,记录一下。

前些天搞了个服务器,今天抽时间配置一下,发现使用apt-get安装东西的时候总是会失败,提示需要apt-get update,但是执行后又会报错“W: Some index files failed to download. They have been ignored, or old ones used instead.”,想了想应该是源的问题,于是查了一下Ubuntu更改下载源的方法,记录一下。

  • 首先系统自带的apt-get源配置文件在这里

     /etc/apt/sources.list
  • 以防万一备份一下

     cp /etc/apt/sources.list /etc/apt/sources.list.bak
  • 查看自己的系统Codename

    lsb_release -c
    ## Codename:    bionic
    系统 对应Codename
    12.04 precise
    14.04 trusty
    15.04 vivid
    15.10 wily
    16.04 xenial
    18.04 bionic
    20.04 focal
  • 根据自己的Codename配置对应的源地址,阿里云镜像站
  • 最后编辑/etc/apt/sources.list源文件,改为以下内容

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  • 或者清华大学源
  • 重新试一下,OK

    apt-get update
相关文章
|
26天前
|
Ubuntu NoSQL 关系型数据库
Ubuntu系统下安装常用软件
Ubuntu系统下安装常用软件
57 0
Ubuntu系统下安装常用软件
|
1月前
|
Ubuntu Linux C语言
Ubuntu下安装vscode,并解决终端打不开vscode的问题
Ubuntu下安装vscode,并解决终端打不开vscode的问题
146 0
|
1月前
|
Ubuntu Docker 容器
如何在Ubuntu上安装Docker?
【2月更文挑战第10天】
257 0
|
2月前
|
负载均衡 Ubuntu 应用服务中间件
|
28天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
68 0
|
1天前
|
Ubuntu Linux Python
Linux(15)Ubuntu安装ninja构建工具
Linux(15)Ubuntu安装ninja构建工具
8 0
|
1天前
|
Ubuntu Linux 数据安全/隐私保护
Linux(7)Ubuntu20.04 arm64安装Docker
Linux(7)Ubuntu20.04 arm64安装Docker
8 0
|
1天前
|
存储 Ubuntu Docker
如何在 Ubuntu 上安装 Docker?
【4月更文挑战第17天】
26 8
如何在 Ubuntu 上安装 Docker?