目录

一、为什么要换源

二、debian系列操作系统换源

(1)备份原来的源

(2)创建新的源

(3)更新apt软件源

三、红帽系列操作系统换源

(1)下载并替换

(2)生成yum缓存

(3)更新

(4)禁用盗版提示


一、为什么要换源

1.默认的软件包仓库都在国外,apt-get或者yum下载软件包很慢。换成国内的仓库源就快了;

2.redhat系统的yum源是要收费的,可以换成免费的centos的yum源。都是yum源是兼容的。

二、debian系列操作系统换源

(1)备份原来的源

sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup

(2)创建新的源

sudo vim /etc/apt/sources.list

复制以下内容并保存(阿里云源):
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

(3)更新apt软件源

sudo apt-get update

三、红帽系列操作系统换源

当前是redhat操作系统,要换成阿里的centos8的yum源:

(1)下载并替换

cd /etc/yum.repos.d/

wget https://mirrors.aliyun.com/repo/Centos-8.repo

mv redhat.repo redhat.repo_bak                             //备份原来的yum源

mv Centos-8.repo redhat.repo                                //替换原来的yum源

(2)生成yum缓存

yum makecache                                                     //把yum源上所有包的信息下载到本地

(3)更新

yum -y update                                                        //-y选项是下载过程中对所有提问都回答yes

(4)禁用盗版提示

修改以下两个文件的Enable=0来禁用Subscription Management的提示

vim /etc/yum/pluginconf.d/product-id.conf

vim /etc/yum/pluginconf.d/subscription-manager.conf

发表回复