ubuntu全版本通用换源教程_玄予的博客-CSDN博客_ubuntu换源
(1条消息) Ubuntu 22.04换国内源 清华源 阿里源 中科大源 163源_nudt_qxx的博客-CSDN博客_ubuntu国内源哪个好
一、提要?
????????在修改国内数据源的时候,切不可以将网上搜索到的文档直接拷贝进/etc/apt/sources.lst文件内,因为数据源和当前的ubuntu版本名称是密切相关的。必须修改成当前版本的名称,才能不出差错。
二、确定当前版本
????????每个版本的源都是不同的,如果源的版本不同就会出现很多的错误,比如gcc缺少依赖项等。
????????查看当前版本指令:
lsb_release -a
No LSB modules are available. Distributor ID:?? ?Ubuntu Description:?? ?Ubuntu 20.04.4 LTS Release:?? ?20.04 Codename:?? ?focal
查看版本的代号和版本
release就是该ubuntu的版本号
codename就是该版本的代号
三、如何修改/etc/apt/sources.list
然后打开源文件:
sudo vim /etc/apt/sources.list
将原来的内容全部删除
将源地址加入进去:
deb http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse ? deb http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse ? deb http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse ? deb http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse ? deb http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universemultiverse
codename就是课该版本的代号,比如说我的是22.04版本的(jammy),我的源就是
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
四、修改成国内数据源
?应用版本信息搜索:
lsb_release -a
(base) huatec@huatec-GW:~$ lsb_release -a No LSB modules are available. Distributor ID:?? ?Ubuntu Description:?? ?Ubuntu 20.04.4 LTS Release:?? ?20.04 Codename:?? ?focal
看到,版本名称是 focal;而数据源与此名要对应;
编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份):
4.1 清华源
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 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
然后执行命令:
sudo apt-get update sudo apt-get upgrade
其他几份国内源如下:
4.2 阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src 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-backports main restricted universe multiverse ?
4.3 中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
4.4 网易163源
deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
( 将以上四个源粘到/etc/apt/sources.lst就可以了。)
|