标签: apt

  • Debian 11 bullseye 更换国内源出现的Certificate问题解决方法 图文教程

    Debian 11 bullseye 更换国内源出现的Certificate问题解决方法 图文教程

    可用的国内源

    由阿里云提供的 Debian 镜像源:

    deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
    deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
    deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
    deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
    deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
    deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
    deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
    deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

    由腾讯提供的 Debian 镜像源:

    deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib
    deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib
    deb https://mirrors.tencent.com/debian-security/ bullseye-security main
    deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main
    deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
    deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
    deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
    deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib

    由北京清华大学提供的 Debian 镜像源:

    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

    由中国科学技术大学提供的 Debian 镜像源:

    deb http://mirrors.ustc.edu.cn/debian bullseye main contrib non-free
    deb-src http://mirrors.ustc.edu.cn/debian bullseye main contrib non-free
    deb http://mirrors.ustc.edu.cn/debian bullseye-updates main contrib non-free
    deb-src http://mirrors.ustc.edu.cn/debian bullseye-updates main contrib non-free
    deb http://mirrors.ustc.edu.cn/debian bullseye-proposed-updates main contrib non-free
    deb-src http://mirrors.ustc.edu.cn/debian bullseye-proposed-updates main contrib non-free

    由上海交通大学提供的 Debian 镜像源:

    deb http://mirrors.sjtu.edu.cn/debian bullseye main contrib non-free
    deb-src http://mirrors.sjtu.edu.cn/debian bullseye main contrib non-free
    deb http://mirrors.sjtu.edu.cn/debian bullseye-updates main contrib non-free
    deb-src http://mirrors.sjtu.edu.cn/debian bullseye-updates main contrib non-free
    deb http://mirrors.sjtu.edu.cn/debian bullseye-proposed-updates main contrib non-free
    deb-src http://mirrors.sjtu.edu.cn/debian bullseye-proposed-updates main contrib non-free

    由北京外国语大学提供的 Debian 镜像源:

    deb https://mirrors.bfsu.edu.cn/debian/ bullseye main contrib non-free
    deb-src https://mirrors.bfsu.edu.cn/debian/ bullseye main contrib non-free
    deb https://mirrors.bfsu.edu.cn/debian/ bullseye-updates main contrib non-free
    deb-src https://mirrors.bfsu.edu.cn/debian/ bullseye-updates main contrib non-free
    deb https://mirrors.bfsu.edu.cn/debian/ bullseye-backports main contrib non-free
    deb-src https://mirrors.bfsu.edu.cn/debian/ bullseye-backports main contrib non-free
    deb https://mirrors.bfsu.edu.cn/debian-security bullseye-security main contrib non-free
    deb-src https://mirrors.bfsu.edu.cn/debian-security bullseye-security main contrib non-free

    由华为提供的 Deiban 镜像源:

    deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
    deb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
    deb https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
    deb-src https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
    deb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
    deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
    deb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
    deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib

    由网易提供的 Debian 镜像源:

    deb https://mirrors.163.com/debian/ bullseye main non-free contrib
    deb-src https://mirrors.163.com/debian/ bullseye main non-free contrib
    deb https://mirrors.163.com/debian-security/ bullseye-security main
    deb-src https://mirrors.163.com/debian-security/ bullseye-security main
    deb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
    deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
    deb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib
    deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contrib

    手动更换镜像源

    手动更换 Debian 镜像源配置主要分为以下三步:

    1. 用熟悉的文本编辑器打开 /etc/apt/sources.list 文件(需要 sudo 权限),或是直接执行 sudo apt edit-sources 命令。
    2. 替换文件内容为上面任意一个镜像站的源配置代码并保存。
    3. 运行 sudo apt-get update 命令更新软件索引。

    命令更换镜像源

    使用命令替换镜像源更为快捷。比如在没有更换过数据源的情况下,要使用阿里云的 Debian 镜像源:

    sudo sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list

    这样就完成了默认源到阿里云镜像源的配置。接下来同样需要执行一下 sudo apt-get update 命令更新软件索引。

    上面这个命令的原理在镜像源的地址上。不同的镜像源通常只是域名有所区别,其他部分大致类似。所以之需要通过 sed 命令来修改 /etc/apt/sources.list 这个源配置文件中的域名地址就足够了。

    但这意味着使用这个命令方式修改镜像源的配置时需要格外注意。如果输入的匹配地址或替换地址有误,有可能不会生效,或是导致镜像源异常。遇到这种情况,可以选择上面手动更换镜像源的方式来解决。

    我们可以看到使用的是https协议

    问题描述

    然而修改好配置时,进行sudo apt-get update报错:

    Reading package lists... Done
    W: https://mirrors.aliyun.com/debian/dists/bullseye/InRelease: No system certificates available. Try installing ca-certificates.
    W: https://mirrors.aliyun.com/debian/dists/bullseye-updates/InRelease: No system certificates available. Try installing ca-certificates.
    W: Failed to fetch https://mirrors.aliyun.com/debian/dists/bullseye/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. 
    W: Failed to fetch https://mirrors.aliyun.com/debian/dists/bullseye-updates/InRelease  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. 
    W: Some index files failed to download. They have been ignored, or old ones used instead.
    

    出现安全证书不信任的问题

    解决办法

    有三种解决办法,使用其一即可。

    1. 把https协议换成http协议
    2. 先安装certificate库(安装命令为 sudo apt install ca-certificates ),再修改成阿里云的源地址。有一种不配源怎么安装,不安装怎么配源的死锁感😂
    3. 使用中科大的源,因为他们在这使用的是http协议。
  • Debian9 Stretch如何更换apt源

    Debian9 Stretch如何更换apt源

    前篇我们介绍了 Windows 10启用Linux子系统(WSL) 图文教程, 但是这里的apt源是官方的源,在国内更新比较慢。所以我们这里记录一下如何更换debian9的apt源。

    编辑apt源文件
    /etc/apt/sources.list

    阿里云apt源

    deb http://mirrors.aliyun.com/debian stretch main contrib non-free
    deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free
    deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
    deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
    deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
    deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free

    163源

    deb http://mirrors.163.com/debian/ stretch main non-free contrib 
    deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib 
    deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib deb-src http://mirrors.163.com/debian/ stretch main non-free contrib 
    deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib 
    deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib

    清华源

    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main non-free contrib deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main non-free contrib 
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main non-free contrib 
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main non-free contrib 
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main non-free contrib 
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main non-free contrib 
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main non-free contrib 
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main non-free contrib

    你也可以把”Stretch”换成”jessie”,”wheezy”。分别对应Debian9,Debian8,Debian7版本。

    如何查询自己的Linux版本参考如下:

    cat /etc/issue

    更新apt源

    apt-get update

    通过终端窗口的信息就可以看出来,此时请求的就是阿里云的镜像。

WeChat
↑