使用yum命令进行包的查找与安装

这里举例安装htop命令

一、安装扩展源 epel*

[root@localhost ~]# yum install epel*
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache

二、yum包的查找

[root@localhost yum.repos.d]# yum provides htop
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.njupt.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
htop-2.2.0-3.el7.x86_64 : Interactive process viewer
    :epel

三、可能出现的问题

1、若出现包的安装错误,多数是由于安装源出现问题,这里建议使用阿里云源
实例1:

[root@localhost yum.repos.d]# yum install epel*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
没有可用软件包 epel*
错误:无须任何处理

解决办法:

//进入yum文件存放的路径
cd /etc/yum.repos.d
//简单粗暴,删除所有文件
//有的文件不允许删,不强求,删除普通文件即可
rm *     
//安装阿里云的yum文件
wget -O /etc/yum.repos.d/CentOS-Base.repo    http://mirrors.aliyun.com/repo/Centos-7.repo
//清理缓存
yum clean all
//加载
yum makecache

实例2:

[root@localhost ~]# yum install wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
软件包 wget-1.14-18.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
local.repo
[root@localhost yum.repos.d]# rm *
rm:是否删除普通文件 "local.repo"?y
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo    http://mirrors.aliyun.com/repo/Centos-7.repo
--2020-04-17 13:42:14--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.19.210.114, 111.19.233.248, 111.19.177.243, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.19.210.114|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: /etc/yum.repos.d/CentOS-Base.repo”

100%[=====================================================>] 2,523       --.-K/s 用时 0s

2020-04-17 13:42:14 (501 MB/s) - 已保存 /etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors
Other repos take up 202 M of disk space (use --verbose for details)
[root@localhost yum.repos.d]# yum makecache
正在尝试其它镜像。
(3/10): base/7/x86_64/other_db                                          | 2.6 MB  00:00:00
(4/10): extras/7/x86_64/other_db                                        | 106 kB  00:00:00
(5/10): updates/7/x86_64/filelists_db                                   | 4.5 MB  00:00:01
(6/10): updates/7/x86_64/other_db                                       | 573 kB  00:00:00
(7/10): updates/7/x86_64/primary_db                                     | 7.6 MB  00:00:01
(8/10): extras/7/x86_64/primary_db                                      | 165 kB  00:00:00
(9/10): base/7/x86_64/primary_db                                        | 6.0 MB  00:00:01
(10/10): base/7/x86_64/filelists_db                                     | 7.3 MB  00:00:01
元数据缓存已建立
[root@localhost yum.repos.d]# cd
[root@localhost ~]# yum install epel*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================================
 Package                    架构                 版本                                   大小
===============================================================================================
正在安装:
 epel-release               noarch               7-11               extras                15 k

事务概要
===============================================================================================
安装  1 软件包

总下载量:15 k
安装大小:24 k
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
epel-release-7-11.noarch.rpm 的公钥尚未安装
epel-release-7-11.noarch.rpm                                            |  15 kB  00:00:00
 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-11.noarch                                                   1/1
  验证中      : epel-release-7-11.noarch                                                   1/1

已安装:
  epel-release.noarch 0:7-11

完毕!
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  epel.repo  epel-testing.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors
Other repos take up 202 M of disk space (use --verbose for details)
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                    | 3.7 kB  00:00:00
 * base: mirrors.aliyun.com
正在尝试其它镜像。
(16/16): epel/x86_64/primary_db                                         | 6.8 MB  00:00:00
元数据缓存已建立
[root@localhost yum.repos.d]# yum provides htop
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.njupt.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
htop-2.2.0-3.el7.x86_64 : Interactive process viewer
    :epel



[root@localhost yum.repos.d]# yum install htop
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.njupt.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 htop.x86_64.0.2.2.0-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================================
 Package            架构                 版本                                           大小
===============================================================================================
正在安装:
 htop               x86_64               2.2.0-3.el7                  epel               103 k

事务概要
===============================================================================================
安装  1 软件包

总下载量:103 k
安装大小:218 k
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/htop-2.2.0-3.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
htop-2.2.0-3.el7.x86_64.rpm 的公钥尚未安装
htop-2.2.0-3.el7.x86_64.rpm                                             | 103 kB  00:00:00
 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
 用户ID     : "Fedora EPEL (7) <[email protected]>"
 指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 软件包     : epel-release-7-11.noarch (@extras)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : htop-2.2.0-3.el7.x86_64                                                    1/1
  验证中      : htop-2.2.0-3.el7.x86_64                                                    1/1

已安装:
  htop.x86_64 0:2.2.0-3.el7

完毕!

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45961525/article/details/105581072
今日推荐