快速将yum/dnf/apt-get等默认源改为国内源

众所周知在国内网络使用默认源几乎都是几十KB的速度实在不能忍,换到国内源瞬间下软件基本顶满网络带宽,心情都好了

我用的是阿里云镜像站,其他还有类似网易开源镜像站清华大学开源软件镜像站等同样不错的镜像站,我选了阿里云一是考虑到阿里旗下网站都能经受住双十一狂轰滥炸,技术应该没的说,而是我有阿里云的服务器,那选择阿里云的镜像站也就是很自然的事情了

每个镜像站基本都会提供更改方法,这里只是把Centos/Fedora/Ubuntu常见系统改阿里镜像站的方法贴出来


在镜像站主页只要点击自己操作系统右边help就能查看对应修改方法

Centos

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

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

  • CentOS 5
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

  • CentOS 6
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

  • CentOS 7
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

  1. 运行yum makecache生成缓存

Fedora

  1. 备份
    mv /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.backup
    mv /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo.backup

  2. 下载新的fedora.repo和fedora-updates.repo 到/etc/yum.repos.d/
    wget -O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo
    wget -O /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo

  3. 运行sudo dnf makecache生成缓存(Fedora从22版本弃用yum换成dnf,yum命令还可以用,只是每次使用系统都会提醒换成dnf)

Ubuntu

乌班图的修改最简单了,直接去系统设置里的软件和更新,选择“中国的服务器”下mirros.aliyun.com即可自动使用

posted @ 2016-12-08 17:08  w12n  阅读(3339)  评论(0编辑  收藏  举报