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

相关推荐
Lynnxiaowen1 小时前
今天继续学习shell脚本
linux·运维·学习·云计算·bash
云上小朱1 小时前
文件下载-ubuntu操作系统下载指定文件
linux·shell
hmcjn(小何同学)1 小时前
轻松Linux-9.进程间通信
linux·运维·服务器·c++·bash
月光在发光2 小时前
19_内核模块挂载问题处理
linux·运维·服务器
Liang_GaRy2 小时前
心路历程-Linux如何赋予权限?
linux·运维·服务器
Hello阿尔法2 小时前
基于 NFS 的文件共享实现
linux·嵌入式
打不了嗝 ᥬ᭄2 小时前
【Linux】线程概念与控制
linux·c++
pengfei_M2 小时前
四、FVP启动linux
linux·单片机·嵌入式硬件
路溪非溪2 小时前
Linux的gpio子系统
linux·运维·服务器
范紫涵-19期-工职大2 小时前
虚拟机之CentOS、网络设置的有趣问题
linux·网络·centos