ubuntu更新软件下载源为阿里云

1.概要

2.内容

要将Ubuntu系统的软件下载源更新为阿里云镜像源,可以按照以下步骤操作:

一、备份原有软件源列表文件

在更改源列表之前,备份原始的源列表文件是一个重要步骤。这样做可以在出现问题时方便恢复。执行以下命令来备份/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

或者,也可以使用vim编辑器:

sudo vim /etc/apt/sources.list

在编辑器中,将原有源地址注释掉(在每行前加#)或删除,然后添加以下阿里云源的地址。根据您的Ubuntu版本,选择相应的配置:

Ubuntu 20.04(代号focal)

# 阿里源镜像地址
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-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
Ubuntu 22.04(代号jammy)

# 阿里源镜像地址
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-backports 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 18.04(代号bionic)

# 阿里源镜像地址
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

三、保存并退出文件

nano编辑器中,按Ctrl+X,然后输入Y并按Enter保存并退出。在vim编辑器中,按Esc键退出编辑模式,输入:wq并按Enter保存并退出。

四、更新软件包列表

修改完源列表文件后,需要更新软件包列表,使系统能够使用新的源进行软件包安装和更新。执行以下命令:

sudo apt update

五、升级系统(可选)

如果您希望确保所有软件包都通过新的源进行更新,可以执行以下命令来升级系统:

sudo apt upgrade

注意事项

  • 在修改源列表文件时,请确保输入的阿里云镜像源地址是正确的,并且与您的Ubuntu版本相匹配。
  • 如果您在使用sudo apt update时遇到错误,请检查/etc/apt/sources.list文件是否格式正确,特别是注意没有多余的空格或拼写错误。
  • 如果更新源失败,可能是由于网络问题或源服务器暂时不可用。可以尝试稍后再尝试更新。

通过以上步骤,您就可以将Ubuntu系统的软件下载源更新为阿里云镜像源,从而提高软件包的下载速度。

3.关联链接

4.关联知识

1.ubuntu里的软件和更新里的“下载自”是修改下载源地址的地方吗

是的,在Ubuntu系统中的“软件和更新”设置里,“下载自”选项确实是用于修改下载源地址的地方。以下是具体的操作步骤:

  1. 打开“软件和更新”设置

    • 您可以通过点击系统右上角的系统设置菜单,然后找到并点击“软件和更新”来打开此设置窗口。
  2. 选择“下载自”选项

    • 在“软件和更新”窗口中,您会看到一个名为“下载自”的选项。默认情况下,它可能设置为Ubuntu的官方服务器。
  3. 修改下载源地址

    • 点击“下载自”选项旁边的下拉菜单,您可以选择“其他站点”以手动输入或选择一个新的下载源地址。
    • 如果您知道某个具体的镜像源地址(例如阿里云的镜像源),您可以直接在输入框中输入该地址。
    • 如果您不确定哪个源最适合您,可以选择“选择最佳服务器”选项。Ubuntu将自动测试多个服务器,并为您选择一个最快的服务器。
  4. 保存更改

    • 完成下载源地址的修改后,点击“关闭”按钮。系统可能会提示您是否要重新载入可用软件包列表。选择“重新载入”以确保系统能够使用新的下载源。
  5. 验证更改

    • 您可以通过运行以下命令来验证下载源地址是否已成功更改:

       

      sudo apt update

    • 如果命令执行成功且没有报错,说明您已经成功更改了下载源地址。

请注意,在更改下载源地址时,请确保选择可靠的镜像源,以避免潜在的安全风险。同时,定期更新系统软件包也是保持系统安全和稳定的重要措施。

2.ubuntu 22 版本的软件和更新里的“下载自”里没有“其他站点”的选项,如何修改下载源的地址呢 

在Ubuntu 22.04版本的“软件和更新”设置中,如果“下载自”选项中没有“其他站点”的选项,您仍然可以通过手动编辑配置文件来修改下载源的地址。以下是具体步骤:

一、备份原配置文件

在进行任何修改之前,建议先备份原配置文件,以便在出现问题时能够快速恢复。

  1. 打开终端。

  2. 使用以下命令备份/etc/apt/sources.list文件:

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

二、编辑配置文件

  1. 打开终端。

  2. 使用以下命令编辑/etc/apt/sources.list文件:

    sudo nano /etc/apt/sources.list

    或者,如果您更喜欢使用vim编辑器,可以使用以下命令:

    sudo vim /etc/apt/sources.list

  3. 在编辑器中,删除或注释掉原有的软件源地址。

  4. 添加阿里云镜像源地址。根据您的Ubuntu 22.04版本(代号jammy),可以添加以下配置:

     

    # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
    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-backports 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

三、保存并退出编辑器

  • nano编辑器中,按Ctrl+X,然后按Y确认保存并退出。
  • vim编辑器中,按Esc键退出编辑模式,输入:wq并按Enter保存并退出。

四、更新软件包列表

完成配置文件的修改后,需要更新软件包列表以应用新的下载源地址。

  1. 打开终端。

  2. 使用以下命令更新软件包列表:

    sudo apt update

五、验证更改

您可以通过在终端中运行一些安装或更新命令来验证新的下载源地址是否生效。例如:

sudo apt install net-tools

或者,您可以再次打开“软件和更新”设置,查看“下载自”选项是否已显示为您刚刚配置的阿里云镜像源地址。

通过以上步骤,您就可以成功将Ubuntu 22.04版本的下载源地址修改为阿里云镜像源。请注意,在修改下载源地址时,请确保选择的镜像源是可靠的,并且适合您的网络环境。

3.下载源配置文件分析 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted >
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restric>

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted

 

您提供的华为云镜像源配置看起来大部分是正确的,但最后一行关于jammy-backportsdeb-src部分以及整个配置的最后一部分被截断了。下面是完整的、修正后的华为云镜像源配置,适用于Ubuntu 22.04(代号jammy):

 

# 华为云镜像源配置
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse

使用步骤

  1. 备份原配置文件
    在进行任何修改之前,建议先备份原配置文件。使用以下命令备份/etc/apt/sources.list文件:

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

  2. 编辑配置文件
    使用nanovim编辑器打开/etc/apt/sources.list文件,并将上面的华为云镜像源配置粘贴进去。

  3. 保存并退出编辑器

    • nano编辑器中,按Ctrl+X,然后按Y确认保存并退出。
    • vim编辑器中,按Esc键退出编辑模式,输入:wq并按Enter保存并退出。
  4. 更新软件包列表
    使用以下命令更新软件包列表以应用新的下载源地址:

    sudo apt update

  5. 验证更改
    您可以通过在终端中运行一些安装或更新命令来验证新的下载源地址是否生效。

通过以上步骤,您就可以成功将Ubuntu 22.04版本的下载源地址修改为华为云镜像源。请确保您的网络环境能够访问华为云镜像源,并且该镜像源是可靠的。

3.方案2 

您提供的华为云镜像源配置中,jammy-backports部分的行被截断了,导致配置不完整。下面是修正后的完整华为云镜像源配置,适用于Ubuntu 22.04(代号jammy):

 

# 华为云镜像源配置
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy universe
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse
deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse
deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse

修正说明

  1. jammy-backports部分
    • 修正了debdeb-src行的截断部分,使其完整。
    • jammy-backports通常包含一些backports的软件包,因此建议包含universemultiverse组件。
  2. jammy-security部分
    • 添加了universemultiverse组件,以确保能够获取到这些组件的安全更新。

使用步骤

  1. 备份原配置文件
    使用以下命令备份/etc/apt/sources.list文件:

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

  2. 编辑配置文件
    使用nanovim编辑器打开/etc/apt/sources.list文件,并将上面的华为云镜像源配置粘贴进去。

  3. 保存并退出编辑器

    • nano编辑器中,按Ctrl+X,然后按Y确认保存并退出。
    • vim编辑器中,按Esc键退出编辑模式,输入:wq并按Enter保存并退出。
  4. 更新软件包列表
    使用以下命令更新软件包列表以应用新的下载源地址:

     

    sudo apt update

  5. 验证更改
    您可以通过在终端中运行一些安装或更新命令来验证新的下载源地址是否生效。

通过这些步骤,您就可以成功将Ubuntu 22.04版本的下载源地址修改为华为云镜像源。确保您的网络环境能够访问华为云镜像源,并且该镜像源是可靠的。

4.详细解释一下上面的配置文件 

上面的配置文件是用于配置Ubuntu 22.04(代号jammy)系统使用华为云镜像源。这些配置行告诉Ubuntu的包管理器(APT)从哪些URL下载软件包和更新。下面是对每一行的详细解释:

配置文件详解

 

# 华为云镜像源配置

  • 这是一个注释行,说明该文件的用途。注释行以#开头,APT会忽略这些内容。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted

  • deb:指示APT这是一个二进制软件包的存储库。
  • https://repo.huaweicloud.com/ubuntu-ports/:这是华为云镜像源的URL。ubuntu-ports表示这是为ARM和其他非x86架构提供的存储库。
  • jammy:指定Ubuntu的版本代号。
  • main restricted:指定要使用的组件。main包含官方支持的自由软件包,restricted包含受限制的软件包(如某些驱动程序)。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy main restricted

  • deb-src:指示APT这是一个源代码软件包的存储库。源代码包允许用户编译和定制软件包。
  • 其他部分与上面的deb行相同。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted

  • 类似于上面的deb行,但jammy-updates表示这是用于更新的存储库,包含对mainrestricted组件的安全和错误修复更新。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates main restricted

  • 对应于上面的更新存储库的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy universe

  • universe组件包含社区维护的开源软件包,这些软件包经过Ubuntu的质量保证测试,但不提供官方支持。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy universe

  • universe组件的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe

  • jammy-updates中的universe组件更新。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates universe

  • universe更新组件的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse

  • multiverse组件包含不受Ubuntu支持的软件包,通常是非自由或受版权限制的软件。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy multiverse

  • multiverse组件的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse

  • jammy-updates中的multiverse组件更新。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-updates multiverse

  • multiverse更新组件的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

  • jammy-backports:这个存储库包含一些从更新版本(如开发版本)反向移植到jammy的软件包。它通常用于提供新功能和更新,但可能不如标准存储库稳定。
  • 包含所有组件:mainrestricteduniversemultiverse
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

  • jammy-backports的源代码包。
 

deb https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse

  • jammy-security:这个存储库专门用于安全更新,确保系统的所有组件都接收到重要的安全补丁。
  • 包含所有组件以确保全面的安全覆盖。
 

deb-src https://repo.huaweicloud.com/ubuntu-ports/ jammy-security main restricted universe multiverse

  • jammy-security的源代码包。

总结

这个配置文件为Ubuntu 22.04系统提供了一个全面的软件包来源列表,覆盖了从官方支持的自由软件包到社区维护的开源软件包,再到受限制和非自由的软件包。通过配置华为云镜像源,用户可以更快地下载和更新软件包,因为镜像源通常位于地理位置更接近用户的地方。

 

Ubuntu系统中,如果你想要更换默认的软件下载阿里云镜像站,可以按照以下步骤操作: 1. **打开终端**: 打开终端(Terminal),你可以通过搜索“终端”或者按下`Ctrl + Alt + T`快捷键。 2. **备份当前列表**: 首先,备份当前的列表以防意外,运行以下命令: ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 3. **编辑新列表**: 使用文本编辑器(如`nano`、`vim`或`gedit`)编辑新的列表文件,例如添加阿里云的ppa: ``` sudo nano /etc/apt/sources.list ``` 将原有的官方替换为阿里云提供的对应版本的,比如对于Ubuntu 18.04及更高版本,你可以添加阿里云的`deb`: ``` deb http://mirrors.aliyun.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse ``` 如果使用的是阿里云的非官方PPA,记得替换为相应的链接地址。 4. **添加GPG密钥**: 对于某些特定的镜像站点,可能需要添加其GPG公钥以验证的真实性。查找对应镜像站的GPG密钥,然后添加: ``` sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys [KEY_ID] ``` 5. **更新索引**: 更换源后,需要更新apt索引,以便识别新添加的软件包: ``` sudo apt-get update ``` 6. **安装所需软件**: 现在可以正常安装软件了,例如: ``` sudo apt-get install [package_name] ``` 7. **检查更新**: 完成上述步骤后,你可以尝试检查是否有可用的软件更新,确认阿里云镜像是否有效: ``` sudo apt-get upgrade ``` 完成以上步骤后,你的Ubuntu系统就切换到了阿里云的镜像站。注意,在首次使用新时可能会因为缺少一些依赖库而遇到问题,这时可以手动解决。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值