ubuntu安装yum

ubuntu安装yum

最近搞了一台服务器,自己折腾的时候用到了yum,发现使用apt-get下载yum时一直报错:

root@iZbp1cml7iso80jlaxx2uZ:/tjy# apt-get install yum
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package yum

网上搜了半天,解决方案无非是:

apt-get update
apt-get upgrade

但是根据我的实际情况,更新apt的库后没有用

最终解决方案:

  1. 备份sources.list文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
  1. 修改源
sudo vim /etc/apt/sources.list

​ 进入vim后

  • 进入Normal模式(按Esc键)。

  • 输入ggdG并按Enter键。这将会从当前光标位置开始到文件的最后行都被删除。

  • 删除过后,我们先查看服务器的ubuntu版本

  • 进入清华镜像源获取镜像内容,

    • 在这里插入图片描述

    • 选好ubuntu版本后复制框中内容至/etc/apt/sources.list

    • 在/etc/apt/sources.list的第一行再加入:

      • deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
        
      • 在我的机子上,sources.list内容如下:

        deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
        # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
        deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
        # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
        deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
        # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
        deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
        # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
        
        deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
        # deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
        
        # 预发布软件源,不建议启用
        # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
        # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
        
  • 最后输入":wq"再回车就修改完毕了

  1. 修改过后,需要从新的源加载
sudo apt-get update
  1. 之后我们再安装yum:
sudo apt-get install yum

这时候我遇到了报错:

root@iZbp1cmlu7iso80jlaxx2uZ:/etc/apt# sudo apt-get install yum
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package yum
root@iZbp1cmlu7iso80jlaxx2uZ:/etc/apt# sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 40976EAF437D05B5
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.J976Sq2yFx/gpg.1.sh –keyserver keyserver.ubuntu.com –recv-keys 40976EAF437D05B5
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
usage: gpg [options] [filename]
root@iZbp1cmlu7iso80jlaxx2uZ:/etc/apt# sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 3B4FE6ACC0B21F32
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.1L1qF3G0X7/gpg.1.sh –keyserver keyserver.ubuntu.com –recv-keys 3B4FE6ACC0B21F32
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
usage: gpg [options] [filename]

从报错提示可看出 没有指定的公钥,执行命令安装指定的公钥即可

  1. 安装公钥(后8位即可代表公钥):
sudo apt-key adv --recv-keys --keyserver keyserver.Ubuntu.com 437D05B5
sudo apt-key adv --recv-keys --keyserver keyserver.Ubuntu.com C0B21F32
  1. 安装公钥后,重新加载apt库
apt-get update
apt-get upgrade

出现了以下警告:

The following packages have unmet dependencies:
 python3-six : Breaks: libpython-stdlib (< 2.7.18) but 2.7.5-5ubuntu3 is to be installed
               Breaks: python-minimal (< 2.7.18) but 2.7.5-5ubuntu3 is to be installed
 python3-yaml : Breaks: libpython-stdlib (< 2.7.18) but 2.7.5-5ubuntu3 is to be installed
                Breaks: python-minimal (< 2.7.18) but 2.7.5-5ubuntu3 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
  1. 我们根据提示安装所需即可

    sudo apt install libpython-stdlib
    sudo apt install python-minimal
    
  2. 最后,终于安装成功!

sudo apt-get install yum

成果展示:
在这里插入图片描述

后续问题:

安装好yum后,尝试使用yum安装一些应用,结果报错:

root@iZbp1cmlu7iso80jlaxx2uZ:/tjy# yum -y install mlocate
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 You can enable repos with yum-config-manager --enable <repo>
root@iZbp1cmlu7iso80jlaxx2uZ:/tjy# yum repolist all
repolist: 0

这是因为我们没有repo文件…

后来查阅相关资料后才发现其实Linux系统基本上分为两大类:

RedHat系列:Redhat、Centos、Fedora等

  • 使用 yum 命令安装软件包

Debian系列:Debian、Ubuntu等

  • 使用 apt-get 命令安装软件包

⚠️因此由于Ubuntu属于Debian系列中直接用apt-get进行软件包下载即可,至于在Ubuntu中安装yum则是一个十分愚蠢的操作😂,这真的给本人好好上了一课。

个人博客:点击此处 欢迎一起交流学习!

  • 16
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

seu_donn

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

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

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

打赏作者

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

抵扣说明:

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

余额充值