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

相关推荐
安红豆.14 分钟前
Linux基础入门 --13 DAY(SHELL脚本编程基础)
linux·运维·操作系统
..空空的人14 分钟前
linux基础指令的认识
linux·运维·服务器
penny_tcf14 分钟前
Linux基础命令halt详解
linux·运维·服务器
荣世蓥1 小时前
10.2 Linux_进程_进程相关函数
linux·运维·服务器
安全不再安全3 小时前
Linux 安装 yum
linux·运维·centos
水饺编程3 小时前
【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,1-2
linux·嵌入式硬件·fpga开发
suri ..3 小时前
【Linux】-----进程第二弹(优先级,环境变量)
linux·运维·服务器
Jay-juice3 小时前
Makefile入门
linux·运维·服务器
Maer094 小时前
WSL (Linux)配置 Rust 开发调试环境
linux·运维·rust
幻世顽灵4 小时前
Linux / Steam deck 解压问题/解压失败
linux·steamdeck