当前位置: 首页 > news >正文

Ubuntu 24.04 更换国内软件源(以阿里云为例)

方法一:一键脚本配置

#!/bin/bash# 备份原有配置
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%Y%m%d%H%M%S)# 写入阿里云源配置
sudo tee /etc/apt/sources.list << 'EOF'
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
EOF# 更新缓存
sudo apt update
sudo apt upgrade -y

方法二:命令行配置

第1步:备份原有源配置
# 备份原有源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
第2步:编辑软件源列表
# 使用vi编辑器打开源列表文件
sudo vi /etc/apt/sources.list
第3步:替换为阿里云源

将文件内容替换为以下内容:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
第4步:更新软件包列表
# 更新软件包列表
sudo apt update# 升级已安装的软件包(可选)
sudo apt upgrade

其他国内镜像源选择

如果您想使用其他镜像源,只需将上述配置中的 mirrors.aliyun.com 替换为:

  • 腾讯云: mirrors.cloud.tencent.com
  • 华为云: repo.huaweicloud.com
  • 清华源: mirrors.tuna.tsinghua.edu.cn
  • 中科大源: mirrors.ustc.edu.cn

验证配置是否成功

# 检查源是否正常
sudo apt update# 查看当前使用的源
sudo apt policy# 测试安装软件包
sudo apt install htop

注意事项

  1. 版本对应: Ubuntu 24.04 的代号是 “Noble Numbat”,在源配置中对应 noble

  2. 网络连接: 确保服务器可以正常访问互联网

  3. 安全性: 建议使用https协议的镜像源,如 https://mirrors.aliyun.com

  4. 恢复原配置: 如果出现问题,可以恢复备份:

    sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list
    sudo apt update
    

国内常用镜像源地址

提供商主地址备注
阿里云https://mirrors.aliyun.com/ubuntu/速度快,覆盖广
腾讯云https://mirrors.cloud.tencent.com/ubuntu/腾讯云用户推荐
华为云https://repo.huaweicloud.com/ubuntu/华为云用户推荐
清华源https://mirrors.tuna.tsinghua.edu.cn/ubuntu/教育网推荐

完成以上步骤后,您的Ubuntu 24.04系统就会使用国内的镜像源,软件下载速度将得到显著提升。

http://www.dtcms.com/a/597735.html

相关文章:

  • 【Advanced Engineering Informatics 1区TOP】ELA-YOLO:一种基于线性注意力的高效钢铁表面缺陷检测方法
  • 【优选算法】LinkedList-Concatenate:链表的算法之契
  • 网站建设哪家go好app开发公司倒闭了怎么办
  • 创世网站建设 优帮云制作网页的步骤
  • LIN总线校验和对比解析
  • Vue.js 响应接口
  • 上海外贸建站黟县网站建设
  • 前进方向坡度角算法开发计划
  • ps插件国外网站网站建设需要哪些步骤 谢谢
  • 织梦cms做好的网站怎样上传到服务器中国住房与城乡建设厅网站
  • 在线教程丨Deepseek-OCR以极少视觉token数在端到端模型中实现SOTA
  • Gorm(十四)的多条件叠加
  • 网站设计班培训郑州网站关键词排名技术代理
  • 网络流dinic与EK
  • 网络编程核心:套接字绑定(bind函数)与 IP 地址转换处理
  • 百度建站东莞著名网站建设
  • 如何选择邯郸网站制作做外贸网站维护费是多少
  • 【SCI复现】高比例可再生能源并网如何平衡灵活性与储能成本?虚拟电厂多时间尺度调度及衰减建模
  • CodeBuddy AI IDE:全栈AI开发平台实战
  • 购物网站开发教程 视频大流量网站 文章点击
  • 研究人员诱导ChatGPT对自身实施提示注入攻击
  • 数据结构与算法实验(黑龙江大学)
  • 孤客截图工具 Pro - 从开发到打包的完整指南
  • 山东德州最大的网站建设教学学校网站php源码|班级主页教师博客学生博客|学校网站织梦仿
  • 基于librespot的定制化Spotify客户端开发:开源替代方案的技术实践与优化
  • 主从同步配置的步骤
  • 个人使用网站wordpress用户设置
  • vps网站目录是灰色的生活中实用的产品设计
  • mysql主备配置(对比postgresql)
  • mysql tidb like查询有换行符内容问题解决