Ubuntu配置apt国内源

Ubuntu APT源配置

简介

目前,Linux系统已经逐渐被很多开发者所接受和喜好,尤其是Ubuntu系统更是将Linux的桌面系统做的相当完善,本文主要介绍修改Ubuntu默认软件安装工具apt软件源,这是考虑到Ubuntu的默认源在国外速度较慢,本文修改为阿里源。

具体步骤

备份配置文件

以防万一,需要将原来的apt源配置文件备份,使用下面的命令即可。(apt软件源配置文件为/etc/apt/sources.list,记录所有软件包的仓库,同类型的还有同级目录下sources.list.d/的以list为后缀的文本文件。)
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

查看系统代号

很多时候网上查阅apt源配置教程,得到的结果不太一样,这是因为Ubuntu每个版本的系统代号都不一致,通过命令lsb_release -c查看。例如,Ubuntu18.04的代号如下。

在这里插入图片描述

修改配置文件

将第一步中的配置文件修改如下,更改为阿里源,注意格式。

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

如图。

在这里插入图片描述

上述的格式如下。

deb http://site.example.com/debian distribution component1 component2 component3
deb-src http://site.example.com/debian distribution component1 component2 component3

后面的几个参数是对软件的分类,Ubuntu下主要是四个mainrestricteduniversemultiverse

更新软件列表

执行sudo apt-get update,此时可能会报错GPG error: http://dl.google.com/linux/chrome/deb stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 78BD65473CB3BD13,这是公钥的问题,执行sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 报错说明的公钥即可添加,此时再次执行sudo apt-get update即可更新软件列表。

更新软件包

执行命令sudo apt-get upgrade进行已安装的软件更新。

补充说明

本文主要介绍如何修改Ubuntu18.04的默认apt软件源为阿里源,加速软件包的安装。

发布了234 篇原创文章 · 获赞 148 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/zhouchen1998/article/details/104496149