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

相关推荐
博语小屋3 分钟前
进程查看
linux
Sadsvit12 分钟前
Linux Vim 编辑器使用指南
linux·编辑器·vim
IT摆渡者15 分钟前
Wireshark攻防实战
linux·服务器·经验分享·笔记
木宇(记得热爱生活)21 分钟前
Ubuntu卡在启动画面:显卡驱动与密码重置
linux·运维·ubuntu
LCY13327 分钟前
Linux系统部署k8s集群
linux·运维·kubernetes
勤匠1 小时前
CentOS 7部署Redis
linux·redis·centos
段嘉许OvO2 小时前
Red靶机攻略
linux·运维·服务器
BenjaminQA3 小时前
python cli命令 cli工具命令 自定义cli命名 开发 兼容 window、mac、linux,调用示例
linux·python·macos·cli·cli命令
仍然探索未知中3 小时前
Linux守护进程
linux·运维·服务器