Ubuntu各个版本换源方法

本文档详细介绍了如何根据Ubuntu的不同版本(从20.10到16.04)更换为阿里源或清华源。首先查看Ubuntu版本,然后备份原有软件源,接着使用vim编辑软件源文件,替换为对应版本的阿里云或清华大学镜像源,最后更新软件源。
摘要由CSDN通过智能技术生成

Ubuntu各个版本换源阿里源、清华源

1.查看unbuntu版本名

用以下命令查看版本名:

lsb_release -c

Ubuntu版本名与系统名对应关系

系统名版本名
Ubuntu 20.10groovy
Ubuntu20.04focal
Ubuntu19.10eoan
Ubuntu19.04disco
Ubuntu18.04bionic
Ubuntu16.04xenial

2.备份原软件源

为了防止修改错误且找不到原来的软件源,将原来的软件源文件备份在相同文件夹下,使用命令:

sudo cp -v /etc/apt/sources.list /etc/apt/sources.list.backup

3.vim打开软件源文件

sudo vim /etc/apt/sources.list
  • a进入追加模式,上下左右键控制光标,将原有内容删除或注释掉(在行首添加#
  • 复制对应版本的软件镜像源,在文件末尾粘贴(crtl+shift+v
  • esc退出编辑模式,输入:wq保存退出

4.对应版本软件源

Ubuntu20.10

  • 阿里源:

    deb http://mirrors.aliyun.com/ubuntu/ groovy main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ groovy-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ groovy-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ groovy-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ groovy-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ groovy main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ groovy-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ groovy-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ groovy-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ groovy-backports main restricted universe multiverse
    
  • 清华源:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-proposed main restricted universe multiverse
    

Ubuntu20.04

  • 阿里源:

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    
  • 清华源:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
    

Ubuntu19.10

  • 阿里源:

    deb http://mirrors.aliyun.com/ubuntu/ eoan main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ eoan-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ eoan-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ eoan-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ eoan main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ eoan-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ eoan-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ eoan-backports main restricted universe multiverse
    
  • 清华源:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
    

Ubuntu19.04

  • 阿里源:

    deb http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ disco main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ disco-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ disco-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ disco-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ disco-backports main restricted universe multiverse
    
  • 清华源:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse
    

Ubuntu18.04

  • 阿里源:

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb 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 main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    
  • 清华源:

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    

Ubuntu16.04

  • 阿里源:
    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    
  • 清华源:
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    

5.更新软件源

运行如下两条命令:

sudo apt update
sudo apt upgrade
可以使用以下步骤在 Ubuntu 上离线安装 gcc 12.3.0: 1. 下载 gcc 12.3.0 的代码压缩包,可以从官网下载或者使用其他可靠的镜像站点下载。下载后将其解压缩到某个目录下。 2. 安装依赖项。打开终端,输入以下命令: ``` sudo apt-get update sudo apt-get install build-essential sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev ``` 这些命令将会安装必要的依赖项,包括构建工具链和编译过程中需要的库文件。 3. 进入 gcc 的代码目录,运行以下命令: ``` ./configure --prefix=/opt/gcc-12.3.0 --disable-multilib ``` 这个命令将会进行配置,其中 `--prefix` 指定了 gcc 安装的路径,这里设为 `/opt/gcc-12.3.0`,`--disable-multilib` 表示禁用多架构支持,即只编译生成当前架构的代码。 4. 运行以下命令进行编译: ``` make -j4 ``` 这个命令将会进行编译,`-j4` 表示使用 4 个线程进行编译,可以根据实际情况进行调整。 5. 运行以下命令进行安装: ``` sudo make install ``` 这个命令将会把编译好的 gcc 安装到指定的路径中。 6. 配置环境变量。打开终端,输入以下命令: ``` sudo nano /etc/profile ``` 在文件末尾添加以下内容: ``` export PATH=/opt/gcc-12.3.0/bin:$PATH ``` 保存并退出文件。然后运行以下命令使环境变量生效: ``` source /etc/profile ``` 至此,gcc 12.3.0 已经成功安装。可以在终端中输入以下命令验证是否安装成功: ``` gcc --version ``` 如果输出类似以下内容,则说明安装成功: ``` gcc (GCC) 12.3.0 ```
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BkbK-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值