当前位置:首页 » 《休闲阅读》 » 正文

Ubuntu apt更换国内镜像源,apt 更新源,apt 国内镜像

3 人参与  2024年10月04日 10:40  分类 : 《休闲阅读》  评论

点击全文阅读


更换Ubuntu镜像源教程

概述

本教程将介绍如何在不同版本的Ubuntu中更换为国内镜像源,以提高软件更新和安装速度。以下示例将涵盖Ubuntu 16.04、18.04、20.04、22.04、24.04五个版本。

备份现有镜像源列表

在更改镜像源之前,建议先备份当前的镜像源列表文件/etc/apt/sources.list

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改镜像源列表

使用文本编辑器打开/etc/apt/sources.list文件:

sudo nano /etc/apt/sources.list

将文件内容替换为所需的镜像源列表。以下提供了常用的国内镜像源对应不同版本的配置。

Ubuntu 16.04 (代号:xenial)
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse## 预发布源,不建议启用# deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
Ubuntu 18.04 (代号:bionic)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates 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
Ubuntu 20.04 (代号:focal)
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports 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
Ubuntu 22.04 (代号:jammy)
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports 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
Ubuntu 24.04 (代号:lunar)
deb http://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse## 预发布源,不建议启用# deb http://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse# deb-src http://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse
更新软件包列表

保存并关闭/etc/apt/sources.list文件后,执行以下命令更新软件包列表:

sudo apt update

等待更新完成即可。

常见问题及解决方法

更新失败或速度较慢

尝试更换其他镜像源,如中科大或清华大学的镜像源。检查网络连接是否正常。

权限问题

确保使用sudo命令进行操作。检查/etc/apt/sources.list文件的权限是否正确。

通过上述步骤,您可以在不同版本的Ubuntu中轻松更换为国内的镜像源,从而提升软件更新和安装的速度。


点击全文阅读


本文链接:http://zhangshiyu.com/post/167553.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1