liunx-Ubuntu上apt源的切换

Ubuntu 系统 apt 命令安装软件默认源为国外源 (服务器位于国外),在国内使用速度较慢,建议改为国内的镜像源服务器。目前国内比较好的源,有阿里源,清华源,豆瓣源等

清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/
阿里云开源软件镜像站:https://developer.aliyun.com/mirror/ubuntu

清华大学开源软件镜像站直接可以去配置https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
在这里插入图片描述

一、备份原文件

修改/etc/apt目录下的sources.list,该文件是包管理工具apt用来记录软件包仓库位置的配置文件。同类型的还有在同一目录下包含.list的各文件。备份软件安装源配置文件,以防更换的软件源无法使用,可以使用备份文件再恢复到原来的镜像源地址。
备份命令如下:

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

二、查看版本的代号

lsb_release -c

得到本版本系统的系统代号,可以看到版本代号为:bionic
请添加图片描述
每个版本代号是不一样的,所使用apt配置文件sources.list文件也不一样
详细参考:https://developer.aliyun.com/mirror/ubuntu

三、更新sources.list文件

  • ubuntu 18.04(bionic) 配置如下
deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

四、更新apt

更新软件列表:

sudo apt-get update

更新软件:

sudo apt-get upgrade

如果遇到Certificate verification failed: The certificate is NOT trusted.
建议更新新证书 ca-certificatese(因为https是加密传输的)
1.编辑/etc/apt/sources.list文件,临时将https的源改为http
2.更新证书 ca-certificates
执行以下命令:

sudo apt install ca-certificates
sudo apt-get install --reinstall ca-certificates
sudo apt install apt-transport-https ca-certificates
sudo apt-get update

3、编辑/etc/apt/sources.list文件,改回https

五、具体网站软件搜索及介绍

以阿里云为例:
在这里插入图片描述
搜索软件名称后可进行不同指定仓库的筛选
在这里插入图片描述

六、手动下载安装

如果您手动下载了.deb文件包(例如fish.deb)并希望将其安装到Ubuntu中,您可以使用dpkg命令来完成安装。以下是安装步骤:

1、打开终端,进入包含下载的.deb文件的目录。假设文件位于/path/to/download目录中。

2、使用dpkg命令安装该.deb文件。执行以下命令,将fish.deb替换为您下载的.deb文件的实际文件名:

sudo dpkg -i fish.deb

3、安装过程可能会出现依赖性问题,表示一些需要的软件包尚未安装。如果出现依赖性错误,您可以使用以下命令修复:

sudo apt-get install -f

这将尝试自动解决未满足的依赖性并安装所需的软件包

请注意,手动下载并安装软件包时,请确保您正在安装可信来源的软件。通过官方软件源或受信任的镜像站下载的软件包更加安全可靠。如果您从非官方来源下载软件包,请确保您信任该软件的来源,并且最好仔细检查下载的文件以确保其完整性和安全性。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值