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

相关推荐
funfan051711 分钟前
【运维】Linux/Debian系统时间校准方法简记
linux·运维·debian
Florence2340 分钟前
cuFuncSetCacheConfig
linux·运维·服务器
一尘之中1 小时前
Ubuntu 22.04 上 FastAPI 的完整安装与问题解决指南
ubuntu·fastapi·ai写作
Petal9909121 小时前
内核调试:Linux编译内核源码为deb并更新内核
linux·运维·服务器
用户467244544991 小时前
Linux 进程管理
linux
一个平凡而乐于分享的小比特2 小时前
Linux内核构建三剑客:Kconfig、.config与Makefile关系详解
linux·makefile·kconfig·.config
Dillon Dong2 小时前
服务器运维:Linux 磁盘查看 & 清理常用命令
linux·运维·服务器
ben9518chen2 小时前
Linux用户管理
linux·运维·服务器
用户6135411460162 小时前
xampplinux_v174beta11在 Linux 下的安装与配置步骤
linux
Byron Loong3 小时前
【系统】Mac系统和Linux 指令对比
linux·macos·策略模式