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的库后没有用
最终解决方案:
- 备份sources.list文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
- 修改源
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"再回车就修改完毕了
- 修改过后,需要从新的源加载
sudo apt-get update
- 之后我们再安装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]
从报错提示可看出 没有指定的公钥,执行命令安装指定的公钥即可
- 安装公钥(后8位即可代表公钥):
sudo apt-key adv --recv-keys --keyserver keyserver.Ubuntu.com 437D05B5
sudo apt-key adv --recv-keys --keyserver keyserver.Ubuntu.com C0B21F32
- 安装公钥后,重新加载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.
-
我们根据提示安装所需即可
sudo apt install libpython-stdlib sudo apt install python-minimal
-
最后,终于安装成功!
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则是一个十分愚蠢的操作😂,这真的给本人好好上了一课。
个人博客:点击此处 欢迎一起交流学习!