Ubuntu 安装yum命令 并配置yum源

本文档介绍了在Ubuntu系统中错误使用yum安装导致系统出现问题后,如何正确配置yum并设置CentOS 7.9.2009的源。首先通过创建/etc/yum.repos.d目录,然后编辑配置文件添加多个镜像源,最后执行yum makecache生成缓存,以确保yum能正常安装软件。
摘要由CSDN通过智能技术生成

20220613更新

在Ubuntu使用yum install 安装时候自动升级了系统的一些组件导致系统瘫痪,Ubuntu正确配置和使用yum的方法待更新


直接使用

sudo apt install yum

是可以安装成功,但是这个yum没有配置源,是不能正常安装软件的

创建配置目录

sudo mkdir /etc/yum.repos.d

创建配置源

这里使用的配置版本是CentOS-7.9.2009的源

sudo vi /etc/yum.repos.d/CentOS-Base.repo

输入

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-7.9.2009 - Base
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/os/$basearch/
        http://mirrors.aliyuncs.com/centos/7.9.2009/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/os/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-7.9.2009 - Updates
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/7.9.2009/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/updates/$basearch/
		https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-7.9.2009 - Extras
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/7.9.2009/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/extras/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.9.2009 - Plus
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/7.9.2009/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/centosplus/$basearch/
        https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-7.9.2009 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/7.9.2009/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

生成缓存

yum makecache

至此配置完成
在这里插入图片描述

  • 21
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三千院喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值