当前位置: 首页 > news >正文

更换 Ubuntu 系统 apt 命令安装软件源

更换 Ubuntu 系统 apt 命令安装软件源

清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/

1. Ubuntu 的软件源配置文件 /etc/apt/sources.list

MIRRORS -> 使用帮助 -> ubuntu
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

Ubuntu 系统 apt 命令安装软件默认源为国外源 (服务器位于国外),在国内使用速度较慢,建议改为国内的镜像源服务器。

Ubuntu 的软件源配置文件 /etc/apt/sources.list

yongqiang@yongqiang:~$ cat /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partnerdeb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse
yongqiang@yongqiang:~$

备份软件安装源配置文件,以防更换的软件源无法使用,可以使用备份文件再恢复到原来的镜像源地址。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
yongqiang@yongqiang:~$ lsb_release -c
Codename:       focal
yongqiang@yongqiang:~$
yongqiang@yongqiang:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal
yongqiang@yongqiang:~$
yongqiang@yongqiang:~$ lsb_release -a | grep Codename | awk '{print $2}'
No LSB modules are available.
focal
yongqiang@yongqiang:~$

2. 清华大学开源软件镜像站 - Ubuntu 镜像

本镜像仅包含 32/64 位 x86 架构处理器的软件包,在 ARM (arm64, armhf)、PowerPC (ppc64el)、RISC-V (riscv64) 和 S390x 等架构的设备上 (对应官方源为 ports.ubuntu.com) 请使用 ubuntu-ports 镜像。

2.1 手动替换

Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件备份,将该文件替换为下面内容,即可使用 TUNA 的软件源镜像。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

更换软件安装源

sudo vim /etc/apt/sources.list

选择你的 ubuntu 版本: 20.04 LTS

# 默认注释了源码镜像以提高 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

2.2 命令替换

执行如下命令自动替换

sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list

更新软件列表

sudo apt-get update

更新软件:

sudo apt-get upgrade

3. Certificate verification failed: The certificate is NOT trusted.

Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification.

3.1 更新证书 ca-certificates (建议)

  1. 编辑 /etc/apt/sources.list 文件,临时将 https 源修改为 http 源。
  2. 更新证书 ca-certificates
sudo apt install ca-certificates
sudo apt-get install --reinstall ca-certificatessudo apt-get update
  1. 编辑 /etc/apt/sources.list 文件,将 http 源修改回 https 源。

3.2 https 源修改为 http 源

编辑 /etc/apt/sources.list 文件,将 Ubuntu 对应版本的软件源里的 https 替换成 httphttps 是加密传输,需要证书认证。去掉 s,将 https 源修改为 http 源。

References

https://yongqiang.blog.csdn.net/
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

http://www.lryc.cn/news/9742.html

相关文章:

  • 2023年可见光通信(LiFi)研究新进展
  • Greenplum的两阶段提交
  • 多元回归分析 | CNN-BiLSTM卷积双向长短期记忆神经网络多输入单输出预测(Matlab完整程序)
  • git命令行推送本地分支到远程仓库
  • 在vscode中使用Typescript并运行
  • 【C++提高编程】C++全栈体系(十九)
  • Java版电能表协议解析源码(DL/T645-2007)、Modbus串口虚拟工具、网络串口调试工具分享
  • 2023美赛选题建议 美国大学生数学建模竞赛ABCDEF题
  • 2023,想跳槽的可以再等等
  • Java之滑动窗口详解
  • Webpack(应用一:基本使用,只需六步骤)
  • 【Python小游戏】智商爆棚,推荐一款益智类亲子娱乐首选—某程序员老爸:成语编成填空“游戏”,贪玩女儿1天牢记500词(厉害了我的Python)
  • 使用web3连接Georli测试网络
  • Python uWSGI 的安装配置
  • 033.Solidity入门——20函数的可视范围
  • 智能家居项目(三)之框架设计及框架代码文件工程建立
  • 全网最全的Ansible中常用模块讲解
  • linux程序分析工具
  • Python3,2分钟掌握Doscoart库,你也能成为艺术家。
  • 1225057-68-0,Alkyne PEG4 TAMRA-5,四甲基罗丹明-四聚乙二醇-炔基TAMRA红色荧光染料连接剂
  • Ae:解释素材
  • 无文件攻击
  • JS高级——数据类型
  • 场景案例│数字员工在银行业的典型应用场景,效率及准确率“双高”
  • 2023美国大学生数学建模竞赛选题建议
  • 整合K8s+SpringBoot+gRpc
  • ROS 教程:使用 Moveit C++ 接口进行拾取和放置任务
  • seo细分和切入点
  • PyQt5数据库开发1 4.3 QSqlTableModel 之 Qt项目的创建
  • 【大数据】第三章:详解HDFS(送尚硅谷笔记和源码)