Linux(debian)更换HTTPS源地址

由于我在网络上搜索关于此的文章给的答案都只有HTTP的源,好多方案即使给了HTTPS的源地址也没有给出前面需要安装证书的步骤,因此就有了此片文章

        由于安装好系统后源地址默认是国外的,因此我们需要更换我们国内的安全的快速的源地址,有以下步骤:

1、首先需要备份sources.list文件,他所在目录:/etc/apt/

命令:

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

关于sources.list.old的后缀可以随意命名,只要自己知道即可比如:sources.list.2024.

2、因为需要换成https源地址,所以我们需要安装https相关证书,所以使用原来的源地址首先进行更新。

命令1:

sudo apt-get update

命令2: 

sudo apt-get install --reinstall ca-certificates -y

这里就需要耐心的等待了,过程中如果网速过慢可能会导致失败,但是没关系,找一个网速快的地方再次执行以上的命令即可。

3、下来就可以使用vi命令进行编辑sources.list文件了

sudo vi /etc/apt/sources.list

进入文件后使用dG删除所有,在使用Shift+insert插入下面的源地址,然后使用wq!进行保存。

源地址(我这里选择的是中科大的https源地址[***注意版本 注意版本 注意版本***]):LUG's repo file generator (ustc.edu.cn)

https://mirrors.ustc.edu.cn/repogen/

以下是我选择的版本: 

deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware

        通过以上步骤就换好了https源地址,接着首先进行更新:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

至此,换源步骤完毕

  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

老王·字德發

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

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

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

打赏作者

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

抵扣说明:

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

余额充值