开门见山,Ubuntu的包管理工具是apt-get,所以不必再安装yum。如果要安装其他包需要使用apt-get命令。

# 这里以locate命令为例
sudo apt-get install mlocate

下文就是问题解决的全过程了。

1. 报错 E: Unable to locate package yum

​ 我在学习 Linux 命令的时候需要使用 locate 命令,但是 Ubuntu 的系统里没有安装 locate 命令。根据弹幕的指示我使用了如下命令。

# yum安装locate
sudo yum install mlocate
sudo updatedb
locate -h

​ 然后就会一直出现报错信息yum不存在,我寻思这破服务器咋要啥啥没有,现在看看,确实有点憨。那既然没有yum,就安装呗。于是就出现了题中的问题,属实是骚操作。

file

图1. yum 安装 locate 失败

file

图2. 用 apt-get 安装 yum 的骚操作

2. 修改sources.list

秉承着求知的心态我查找了相关的报错信息,得到做多的答案就是 update ,各种 update upgrade。

# 包括但不限于以下update方法
sudo apt-get update
sudo apt-get upgrade
sudo apt update

​ 最有用的方法竟然没用了,确实让我很苦恼啊。到底是哪方面出了问题呢?在我掠过无数篇相同的文章之后,找到了解决办法。

# 修改 apt-get 源的配置文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
sudo vim /etc/apt/sources.list #修改
sudo apt-get update #更新列表

这里给出部分可用的镜像

阿里云源

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

这里提供vim的一些操作帮助

Shift + I	编辑文档
Esc			退出编辑
:q!		    关闭文档
:wq!		保存文档并关闭

file

图3. 修改之后的 sources.list

修改完毕,再次执行 apt-get install yum,再次报错缺少依赖的库。这个问题好办多了,直接安装。

file

图4. 安装最后的问题-缺少依赖库

# 依赖库的安装
sudo apt-get install python-sqlitecachec       
sudo apt-get install python-urlgrabber
sudo apt-get install python-libxml2
sudo apt-get install python-rpm
sudo apt-get install python-sqlite
sudo apt-get install python-urlgrabber

应该只有这么多需要的,再有其他的再安装。

file

file

图5. 这是最后 yum 安装成功的显示

终于安装好了yum,验证一下是否可用。

file

图6. yum可用

3. 意识到问题没那么复杂

终于搞定了yum,心想这下可以消停了吧。

file

图7. repos相关的报错,解决应该很麻烦

又出错了,没使用过yum不是很理解,但应该是个很麻烦的问题,又得兜一圈。后来发现了一点Linux的常识。

linux系统基本上分两大类

1 RedHat系列:Redhat、Centos、Fedora等

2 Debian系列:Debian、Ubuntu等

RedHat 系列

1 常见的安装包格式 rpm 包,安装rpm包的命令是 “rpm -参数”

2 包管理工具 yum

3 支持tar包

Debian系列

1 常见的安装包格式 deb 包,安装deb包的命令是 “dpkg -参数”

2 包管理工具 apt-get

3 支持tar包

所以问题最终的解法就是用apt-get 安装mlocate。

# apt-get 安装 mlocate
sudo apt-get install mlocate

file

图8. 最终的成功

到这里就结束了?

# 卸载yum
sudo apt-get remove yum

file

图9. 残忍抛弃

总结:Ubuntu使用apt-get就够用了。如果安装需要yum,这里没有解决repos的报错。以后的错误,以后再解决。

作者:|萌褚|,原文链接: http://www.imooc.com/article/325506

文章推荐

drf——全局处理异常、接口文档、jwt介绍、based64编码与解码

聊一聊模板方法模式

在Linux上安装redis7

深入理解python虚拟机:程序执行的载体——栈帧

MySQL InnoDB Architecture 简要介绍

Linux:管道命令与文本处理三剑客(grep、sed、awk)

让代码变得优雅简洁的神器:Java8 Stream流式编程

深度学习之PyTorch实战(5)——对CrossEntropyLoss损失函数的...

SpringBoot的EnableCaching简述

MS SQL Server 删除重复行数据

自己动手写线程池——向JDK线程池进发

golang 方法接收者