yum找出软件包在CentOS/RHEL上安装的路径

时间:2020-01-09 10:44:15  来源:igfitidea点击:

我已经在CentOS/RHEL上安装了htop软件包。
如何找出htop软件包在何处以及以什么路径安装所有文件。
有没有一种简单的方法可以告诉yum CentOS/RHEL的安装位置?

yum命令是用于CentOS/RHEL和克隆的交互式,开源,基于rpm的软件包管理器。
它可以自动为您执行以下操作:

  • 核心系统文件更新
  • 套餐更新
  • 安装新软件包
  • 删除旧包
  • 对已安装和/或者可用的软件包执行查询

yum与其他高级软件包管理器(如apt-get命令/apt命令)相似。

Yum软件包安装位置

出于演示目的安装htop软件包的语法如下:

# yum install htop

要列出由称为htop的yum软件包安装的文件,请运行以下rpm命令:

# rpm -q {packageNameHere}
# rpm -ql htop

输出示例:

/usr/bin/htop
/usr/share/doc/htop-2.0.2
/usr/share/doc/htop-2.0.2/AUTHORS
/usr/share/doc/htop-2.0.2/COPYING
/usr/share/doc/htop-2.0.2/ChangeLog
/usr/share/doc/htop-2.0.2/README
/usr/share/man/man1/htop.1.gz
/usr/share/pixmaps/htop.png

如何使用repoquery命令查看yum软件包安装的文件

首先使用yum命令安装yum-utils软件包:

# yum install yum-utils

输出示例:

Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-42.el7 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-42.el7.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-42.el7.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================
Package           Arch      Version             Repository                       Size
=======================================================================================
Installing:
yum-utils         noarch    1.1.31-42.el7       rhui-rhel-7-server-rhui-rpms    117 k
Installing for dependencies:
libxml2-python    x86_64    2.9.1-6.el7_2.3     rhui-rhel-7-server-rhui-rpms    247 k
python-kitchen    noarch    1.1.1-5.el7         rhui-rhel-7-server-rhui-rpms    266 k
 
Transaction Summary
=======================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 630 k
Installed size: 3.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): python-kitchen-1.1.1-5.el7.noarch.rpm                    | 266 kB  00:00:00     
(2/3): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                | 247 kB  00:00:00     
(3/3): yum-utils-1.1.31-42.el7.noarch.rpm                       | 117 kB  00:00:00     
--------------------------------------------------------------------------------------
Total                                                     1.0 MB/s | 630 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-kitchen-1.1.1-5.el7.noarch                                   1/3 
  Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64                               2/3 
  Installing : yum-utils-1.1.31-42.el7.noarch                                      3/3 
  Verifying  : libxml2-python-2.9.1-6.el7_2.3.x86_64                               1/3 
  Verifying  : yum-utils-1.1.31-42.el7.noarch                                      2/3 
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                                   3/3 
 
Installed:
  yum-utils.noarch 0:1.1.31-42.el7                                                     
 
Dependency Installed:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3      python-kitchen.noarch 0:1.1.1-5.el7     
 
Complete!

如何使用YUM列出已安装软件包的内容?

现在运行repoquery命令,如下所示:

# repoquery --list htop

或者

# repoquery -l htop

您也可以使用type命令或者command命令查找给定二进制文件(例如httpd或者htop)的位置:

$ type -a httpd
$ type -a htop
$ command -V htop