靳闯博客 记录是一种习惯 、分享是一种态度
  • 波浪
  • 波浪
  • 波浪
  • 波浪
Centos | Ubuntu更改为阿里云的yum源
发表于: | 分类: 技术积累 | 标签: Linux Yum ubuntu

Centos

1、进入到/etc/yum.repos.d/目录下,备份之前的CentOS-Base.repo地址。

cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak

2、下载阿里云yum源,对应系统版本

#centos8:
wget  http://mirrors.aliyun.com/repo/Centos-8.repo -O CentOS-Base.repo

#centos7:
wget  http://mirrors.aliyun.com/repo/Centos-7.repo -O CentOS-Base.repo

#centos6:
wget  http://mirrors.aliyun.com/repo/Centos-6.repo -O CentOS-Base.repo

#centot5:
wget  http://mirrors.aliyun.com/repo/Centos-5.repo -O CentOS-Base.repo

3、将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

yum clean all 
yum makecache

如果你在执行上面这边命令时,报错:

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

建议用如下方法解决:检查/etc/yum.repos.d/下是否有epel.repo文件,如果有,重命名为epel.repo_bak 千万不能以.repo格式备份,然后在执行一次上面的命令即可!


Ubuntu

1,由于ubuntu 官方的源下载很慢,我们可以替换为国内的源提高下载速度更换为阿里云的源

首先备份本地的源
cp /etc/apt/sources.list /etc/apt/sources.list.bak

#修改文件 删除原有内容,添加下面内容
vim /etc/apt/sources.list
#Ubuntu 14.04.5 LTS
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
#Ubuntu 16.04 LTS

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
#Ubuntu 18.04 LTS (bionic)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

2,更新源

apt-get update

商业转载请联系作者获得授权,非商业转载请注明出处 本文地址:https://me.jinchuang.org/archives/37.html

如果这篇文章帮助到了你,我感到十分荣幸!


📬 评论留言 ↴

TOP