ubuntu 设置apt-get国内源

本文详细介绍了如何在Ubuntu系统中更改软件源为国内镜像,包括使用 ustc 和 tuna 清华大学以及阿里云的镜像源,以提高更新和下载速度。同时,还提供了处理更新时可能出现的证书问题的方法,如导入必要的GPG密钥,并安装`ca-certificates`以解决系统证书问题。最后,提到了根据系统版本选择合适的镜像源以及访问镜像源网站获取更多帮助。
摘要由CSDN通过智能技术生成

1.修改sources.list

cd /etc/apt
#将文件重命名为sources.list.backup--备份
sudo mv sources.list sources.list.backup
#新建sources.list文件。(这样目的是以防出问题时候,还可以把sources.list改回来)
sudo vim sources.list
#设置国内源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse


deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

2.更新

sudo apt-get update

3. 更新遇到问题

3.1证书问题

如果更新遇到类似这种应该是证书问题

W: GPG error: http://security.ubuntu.com/ubuntu xenial-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://security.ubuntu.com/ubuntu xenial-security InRelease' is not signed.

可以试试导入证书:

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32

3.2 No system certificates available 

需要先安装ca-certificates

apt-get install ca-certificates

4. 根据系统版本选择源

cat /etc/issue

 

 4.1清华镜像源

打开浏览器,访问 https://mirror.tuna.tsinghua.edu.cn/help/ubuntu :

4.2阿里源

打开浏览器,访问 https://developer.aliyun.com/mirror/ubuntu :

参考:

Ubuntu设置国内镜像源_ubuntu镜像-CSDN博客

### 回答1: Ubuntu 18.04 是一款伟大的操作系统,它可以通过 apt-get 指令进行软件安装及更新。但是在使用时,有时会遇到下载缓慢或无法下载的问题,这时候我们就需要更换 apt-get 的源。 apt-get 源是指软件存放的服务器地址,可以理解为软件的下载站点。Ubuntu 官方提供了多个 apt-get 源,其官方源位于国外,下载速度较慢。因此,为了提高软件下载速度,我们可以更换国内的 apt-get 源。 目前常见的国内 apt-get 源有阿里云、中科大和清华大学等。其中,阿里云的 apt-get 源速度较快、更新比较及时,中科大的 apt-get 源提供了多个镜像,可供选择,清华大学也是较为优秀的 apt-get 源之一。 更换 apt-get 源的方法很简单,可以通过修改 /etc/apt/sources.list 文件来完成。在该文件中,将原先的官方源地址删除,并替换为你想要使用的源地址即可,然后保存文件并输入以下指令:sudo apt-get update 指令用于更新软件源列表,sudo apt-get upgrade 指令用于升级可用的软件包。 总的来说,更换 apt-get 源可以提高软件下载速度和更新软件的效率,但选择哪个源需要根据自己的实际要求进行评估,才能得出最适合自己的 apt-get 源。 ### 回答2: Ubuntu是一个流行的Linux操作系统,而其18版本自带了一个很强大的包管理工具——APT,能够帮助我们方便地安装、升级和删除软件。APT源是一个软件包仓库,类似于应用商店,我们可以从这里获取到软件包和更新。 APT源有两种类型:官方源和第三方源。官方源是由Ubuntu官方提供的,程序包比较稳定可靠。而第三方源通常是由其他开发者或组织提供的,有些可能是非官方且不受官方支持的。 在Ubuntu 18中,APT的默认源在国外,可能会受到网络访问速度的限制,但我们可以使用软件源镜像来解决这个问题。国内的软件源镜像有很多,比如阿里云、清华大学、中国科技大学等。我们可以通过修改APT的源列表来使用这些镜像。 修改源列表的方法: 1.备份原先的源列表:在终端中输入命令sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak,即可将原先的源列表备份。 2.编辑源列表:在终端中输入命令sudo nano /etc/apt/sources.list,用编辑器打开源列表。 3.将官方源修改为软件源镜像,比如将deb http://archive.ubuntu.com/ubuntu/改为deb https://mirrors.aliyun.com/ubuntu/。 4.保存源列表并退出即可。 需要注意的是,由于Ubuntu 18默认的apt源是Security源,安装软件时需要先更新一下软件源才能获取到最新的软件包,可以输入apt update命令进行更新。 总的来说,APT源是Ubuntu系统中非常重要的一部分,我们可以通过修改源来加快软件下载速度,安装需要的软件包,保持系统的更新。 ### 回答3: Ubuntu 18 是一个打算为用户提供全新体验的、开放源代码的基于Linux的操作系统。其中apt是debian系统和Ubuntu系统上的包管理工具,用于工作场合的包安装、更新、卸载管理。ubuntu 18 apt-get源是指Ubuntu18操作系统中的软件源,包含了各种系统软件和应用软件的更新包和应用程序。Ubuntu 18 apt-get源可以让用户方便地下载并安装最新的软件和更新包,同时也可以有效地保证软件的安全性和稳定性。 默认情况下,Ubuntu 18系统中会给用户分配一组本地镜像源,包括了Main、Restricted、Universe、Multiverse四个仓库。其中Main为Ubuntu官方仓库软件,Restricted为商业软件。Universe是开放源码软件,Multiverse包含专有声音、视频驱动等非开放性质软件。用户可以在系统设置里变更apt-get源,选择下载速度最快的镜像源,避免下载过程中的网络卡顿和等待时间。 在使用apt-get指令下载软件或更新时,用户需要在命令行输入软件名称和仓库源地址,例如:sudo apt-get update,或sudo apt-get install google-chrome,这些指令会通过Ubuntu 18 apt-get源来下载软件。用户可以通过更新apt-get源来获取新的软件源或更新源。 总之,Ubuntu 18 apt-get源是Ubuntu系统中的一项重要功能,它能让用户更便捷的获取软件更新和安装新软件,同时所提供的软件都是经过认证的,赋予用户更安全、稳定的体验。用户还可通过添加第三方源来拓展软件和应用的种类。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值