将linux镜像源改为阿里云镜像源

本文详细介绍了如何将Ubuntu的软件源更改为阿里云镜像源,并提供了更改CentOS默认yum源的具体步骤。通过这些操作可以提高系统的更新速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu

首先编辑sources.list这个文件

vi /etc/apt/sources.list

把sources.list文件内容替换成如下

deb http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free

接下来执行以下命令,就完成阿里云kali linux镜像源了

apt-get update

Centos

修改CentOS默认yum源为mirrors.aliyun.com
1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo

1
[root@localhost ~] # mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2、下载ailiyun的yum源配置文件到/etc/yum.repos.d/
CentOS7

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


CentOS6

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


CentOS5

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

 
3、运行yum makecache生成缓存

1
[root@localhost ~] # yum makecache


4、这时候再更新系统就会看到以下mirrors.aliyun.com信息

1
2
3
4
5
6
[root@localhost ~] # yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

在Ubuntu系统中更改默认的软件包镜像源为国内阿里云,可以提高下载速度并减少网络延迟。以下是操作步骤: 1. **更新现有的软件包列表**: ``` sudo apt update ``` 2. **编辑`sources.list`文件**: 打开终端,输入命令: ``` sudo nano /etc/apt/sources.list ``` 然后,在文件底部添加阿里云的软件源。例如,对于主存库,你可以加入: ``` deb http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse ``` 对于非官方的阿里云非主流软件源,如PPA(Personal Package Archive),则替换相应链接。 3. **更换主源**: 删除原有的默认源(通常以 `deb http://archive.ubuntu.com/ubuntu` 开始的那一行)。 4. **保存并关闭`nano`编辑器**: 按`Ctrl + X`, 再按`Y`确认保存,然后按回车键。 5. **刷新新的源列表**: ``` sudo apt update ``` 6. **安装阿里云的apt-key**: 如果需要验证阿里云镜像,运行: ``` sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8F0F9B1 ``` 7. **设置国内软件源为首选**: 使用以下命令将阿里云设置为首选源: ``` sudo sed -i '1i deb http://mirrors.aliyun.com/ubuntu <version> main restricted universe multiverse' /etc/apt/sources.list ``` `<version>`替换成你的Ubuntu版本号,比如`focal`。 完成以上步骤后,Ubuntu系统将优先从阿里云下载软件包。注意这不会影响系统的原始功能,仅影响新软件包的安装和升级。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值