Ubuntu、CentOs更换源(阿里云的源)

ubuntu

  1. 备份当前的apt配置文件

    sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup

  2. 编辑配置文件,将以下内容写到文件中sudo vi /etc/apt/sources.list

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

  3. 更新

    更新源

    sudo apt update

    更新系统中已安装的软件包

    sudo apt upgrade

centos

  1. 备份当前的yum源

    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

  2. 下载新的CentOS-Base.repo 到/etc/yum.repos.d/

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    或者
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

  3. 清空并生成缓存

    yum clean all
    yum makecache

相关推荐
lengjingzju3 分钟前
编译与调试完全指南—第14章 系统配置与调优
linux
大鹏的NLP博客1 小时前
通用 Linux 嵌入式板端 C/C++ ABI 与 Glibc 依赖治理规范
linux·c++·交叉编译
tedcloud1232 小时前
book-to-skill 怎么部署?把技术书和项目文档变成 AI Agent 可复用知识
linux·运维·服务器·人工智能·开源
瀚高PG实验室2 小时前
SQL优化案例:使用分区表优化SQL查询性能
linux·服务器·数据库·sql·microsoft·postgresql
青禾8372 小时前
Linux 系统信息、权限管理与 Python 并发编程(协程与线程)完全指南
linux·python
2301_800954993 小时前
Linux 常用系统信息与进程管理命令速查
linux·运维·服务器
T型码农要学习4 小时前
eMMC_命令整理
linux·驱动开发·emmc
刚入门的大一新生5 小时前
Linux-进程4
linux·运维·服务器
-今昭-5 小时前
MooseFS分布式文件系统
linux·服务器·网络