linux环境下用apt install yum

一、安装

1. 下载yum安装包并解压

   wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
   tar xvf yum-3.2.28.tar.gz 

2. 进入目录并install

cd yum-3.2.28
sudo apt install yum

参考引用:linux中安装yum简单方法 - 简书

3. 配置yum repo

创建文件

touch /etc/yum/repo.d/CentOS-Base.repo 

(我的/etc/yum/repo.d下没有文件)

下载Centos-7.repo(根据你的Centos version选择对应的)

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

 4. 更新

yum check-update
yum update
yum clean all

参考:centos镜像-centos下载地址-centos安装教程-阿里巴巴开源镜像站

二、可能遇到的问题

1. apt install  yum 时报:E: Unable to locate package yum

 搜了下,解决方案是用:sudo apt-get update

但是发现我的apt 的软件源配置的有问题,故重新配了软件源

2. 修改软件源

vi /etc/apt/sources.list

deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

参考:https://zhuanlan.zhihu.com/p/15087295

3. 更新apt软件源后,再次 sudo apt-get install yum,发现:        

 很明显,没装python-sqlitecachec和python-sqlitecachec, 用apt install

sudo apt-get install python-sqlitecachec
sudo apt-get install python-urlgrabber

4. 使用yum repolist时报:

https://mirrors.aliyun.com/centos/%24releasever/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 "

发现url中有%24releasever,这个是变量,没有被系统识别,故用了简单粗暴的方法,将CentOS-Base.repo用$releasever变量的地方全部替换成对应的版本号,我用的是7

查看版本号命令:

lsb_release -a
vim CentOS-Base.repo
:%s/$releasever/7/g

参考:yum源中$releasever不能被系统识别_9t night的博客-CSDN博客

Linux系统中,aptyum都是常用的包管理工具。APT是Debian和Ubuntu中的工具,而YUM(Yellowdog Updater, Modified)则是Red Hat系列的工具。虽然APTYUM都用来管理软件包,但它们的运行方式和语法有所不同。 在实际使用中,我们有时候需要在不同的Linux系统中使用这两个包管理工具。例如,在Debian系统中想要安装Red Hat系列的软件包,就需要使用YUM。在使用过程中,有时候会遇到一些问题,比如apt install yum无法解析域名。 这种情况通常是由于DNS设置不正确导致的。在Linux系统中,DNS是用来将域名解析为IP地址的服务。如果DNS设置不正确,那么系统就无法解析域名。 解决这个问题的方法也比较简单,只需要检查DNS设置并进行修正即可。首先,可以尝试使用一些常见的DNS服务器地址,例如谷歌的8.8.8.8和8.8.4.4。将这些地址添加到系统的DNS服务器列表中,然后再尝试执行apt install yum命令,应该就可以正常解析域名了。 如果还是无法解决问题,可以尝试清除DNS缓存。在不同的Linux发行版中,清除DNS缓存有不同的方法。例如,在Debian和Ubuntu中,可以使用以下命令来清除DNS缓存: sudo /etc/init.d/dns-clean restart 在CentOS和Red Hat Enterprise Linux中,可以使用以下命令来清除DNS缓存: sudo service nscd restart 总的来说,apt install yum无法解析域名这个问题,通常是由于DNS设置不正确导致的。通过检查DNS设置并进行修正,或者清除DNS缓存,就可以解决这个问题。这个过程中需要注意及时备份重要的数据,避免数据丢失。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值