修改Ubuntu的源列表

#修改Ubuntu的源列表(source list)

环境:win10自带Ubuntu 20.04.1 LTS \n \l

Win10 WSL Ubuntu 根目录实际位置:文件夹里同样输入 \wsl$ 进行查找打开。


  • Main 库
    Main 库由 Ubuntu 官方支持,其中的软件都是开源免费的。Ubuntu 的默认安装中的所有开源软件都在 main 库中,另外还有一些比较重要的服务器软件也被包含在 main 库中。在 Ubuntu 发行版的生命周期中,main 库中的软件会有安全更新,严重的问题会被修复。

    Main 库是 Ubuntu 最重要的软件库,Ubuntu 官方(实际上是 Canonical 公司)承诺在发行版的生命周期中,这里面的每一个软件包都会收到安全补丁和严重问题的修复补丁。比如对于 Ubuntu LTS(长期支持版)来说,支持周期为五年,就是保证在五年内会有安全更新。而这里的安全更新,实际上就是对 main 库中的包进行安全更新。之所以会有这样的保证,也是因为 main 库中的软件都是开源软件,Ubuntu 自己的开发人员就可以修复这些问题而无需依赖第三方。

  • Restricted 库
    Restricted 库中包含 Ubuntu 官方支持的闭源软件(Closed-Source),主要是一些硬件驱动程序。比如运行一些游戏程序,需要安装 NVIDIA 或 AMD 的图形驱动程序来获得最佳的图形硬件性能。这些驱动程序可以通过 Ubuntu 中的其他驱动管理工具来启用。

    Ubuntu 官方将在承诺的支持期内为这些闭源的驱动程序和固件包提供支持。他们致力于让这些驱动程序继续工作,解决任何严重的问题,并堵住任何的安全漏洞。当然,Ubuntu 自己无法做到这一点——当出现问题时,他们必须等待硬件制造商发布新的驱动程序或更新有问题的驱动程序。因为代码不是开源的,所以 Ubuntu 官方无法自己修复它,这就是为什么这里只包含关键的硬件驱动程序的原因(没有其他的封闭源软件得到官方支持)。

  • Universe 库
    Universe 库中存放的是由社区维护的开源软件。这些软件包要么是自动从最新版本的 Debian 库中导入的,要么是由 Ubuntu 社区上传和维护的。

    Ubuntu 不为 universe 库中的软件提供官方支持或更新。即便不能收更新,universe 库中的软件通常也能够运行的很好。所以我们基本上可以放心的使用 universe 库中的软件!
    但是,在服务器系统上,需要我们考虑安装的服务器软件是 main 库的一部分还是 universe 库的一部分。如果它来自 universe 库,您需要关注其安全性更新。如果发现漏洞,您需要自己更新该服务器软件。

    同样在 Ubuntu Software 中,可以在软件的详细信息处看到该软件是否属于 universe 库,比如下图中的 plan 程序就属于 universe 库:

  • Multiverse 库
    Multiverse 库是不受 ubuntu 官方支持的软件、闭源软件和专利授权软件聚集的地方。这是哪些有争议的东西存在的地方。它包括像 Adobe Flash 插件这样的闭源软件,和那些依赖于闭源软件的包,比如 Skype 的插件。它还包括受法律限制的开源软件,例如侵犯专利的音频和视频播放软件。这里不包括 DVD 播放软件——开源的 libdvdcss DVD 播放库存在严重的法律问题。

    Ubuntu 不会在主发行版发布的同时发布这些包,但是我们却可以从这里提供的内容获得便利。在其他 Linux 发行版中,这里的内容通常可以在第三方存储库中找到,比如 Fedora 的 RPM Fusion、openSUSE 的 Packman 等。

    和 universe 库一样,Multiverse 也是一个由社区支持的库,因此这里不会保证有安全更新。

sources.list所在目录:/etc/apt/sources.list
修改sources.list的目的主要是因为ubuntu默认的源地址一般是国外地址,下载安装软件扥度比较慢,可以使用命令"cp sources.list sources.list.bak"备份下。

## 可以将ubuntu默认的源删除掉或者注释掉。添加下面需要的地址,国内网易和阿里的下载较快。
## 其中trusty 是当前ubuntu系统的版本代号。
## Utopic(14.10):   utopic
## Trusty(14.04):   trusty
## Precise(12.04):  precise
## Xenial(16.04):   xenial
## Focal (20.04) focal 
## jammy (22.04):   jammy 

## 20.04
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse

## 163.com
deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

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


## 22.04
## 163
deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse

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

每行开头的deb和deb-src,分别代表直接通过.deb文件进行安装和通过源文件的方式进行安装。
deb或deb-src字段之后,是一段URL,之后是五个用空格隔开的字符串,分别对应相应的目录结构。在浏览器中输入http://archive.ubuntu.com/ubuntu/,并进入dists目录,可以发现有5个目录和前述sources.list文件中的第三列字段相对应。任选其中一个目录进入,可以看到和sources.list后四列相对应的目录结构。

修改完 sources.list文件,在执行命令:

sudo apt update
sudo apt upgrade

在执行sudo apt-get update命令时可能会遇到错误提示:

错误:
W: GPG error: http://extras.ubuntu.com precise Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

解决办法,执行命令:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192

以上是通过通过修改源列表的方式修改,还可以通过如下apt-add-repository命令进行修改(没有试过),add-apt-repository 命令(实质是个python脚本)在source.list里添加 ppa 源了(同时完成导入key)。
语法:


add-apt-repository 'deb uri distribution [component1] [component2] [...]'
add-apt-repository ppa:<ppa_name>

例子:

add-apt-repository 'deb http://archive.debian.org/debian-archive hamm main'
add-apt-repository ppa:gnome-desktop
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
修改Ubuntu的镜像,可以按照以下步骤进行操作: 1. 备份列表:在修改之前,建议先备份原始的列表文件。可以使用以下命令将原始的列表文件备份到sources.backup.list: ``` cp /etc/apt/sources.list /etc/apt/sources.backup.list ``` 2. 打开列表文件:使用文本编辑器(如vi、nano等)打开列表文件。可以使用以下命令打开列表文件: ``` sudo vi /etc/apt/sources.list ``` 3. 更换镜像:在列表文件中,将原始的镜像地址替换为国内的镜像地址。推荐使用清华镜像,可以将以下内容添加到列表文件中: ``` deb https://mirrors.tuna.tsinghua.edu.*** deb https://mirrors.tuna.tsinghua.edu.***iverse deb https://mirrors.tuna.tsinghua.edu.*** multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse ``` 4. 保存并关闭文件:保存对列表文件的修改,并关闭文本编辑器。 5. 更新软件包列表:运行以下命令更新软件包列表,使修改后的镜像生效: ``` sudo apt update ``` 通过以上步骤,就可以成功修改Ubuntu的镜像。请注意,如果需要使用其他镜像,可以查询相关镜像官网,并根据官方提供的指引更换对应的镜像码。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [ubuntu更改镜像](https://blog.csdn.net/qq_57171795/article/details/123109463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [修改ubuntu 18.04的sources.list为阿里或清华镜像的方法](https://download.csdn.net/download/weixin_38730977/14048285)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值