AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 558936
Accepted
checksum
checksum
Asked: 2013-12-04 07:18:14 +0800 CST2013-12-04 07:18:14 +0800 CST 2013-12-04 07:18:14 +0800 CST

如何准确检查yum中是否安装了包?

  • 772

我不断得到类似的答案:

yum list installed | grep bind

或者

rpm -qa | grep bind

但这并不准确,因为我得到了一些其他绑定包的列表,例如:

bind-utils-9.8.2-0.17.rc1.el6_4.5.x86_64
rpcbind-0.2.0-11.el6.x86_64
bind-libs-9.8.2-0.17.rc1.el6_4.5.x86_64
samba-winbind-3.6.9-151.el6.x86_64
samba-winbind-clients-3.6.9-151.el6.x86_64
ypbind-1.20.4-30.el6.x86_64

那不是我想要的。相反,我想准确检查是否已安装绑定核心包。例如。bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6

我希望有类似的东西:

yum check installed bind

但希望有人能阐明这一点。

yum
  • 6 6 个回答
  • 183706 Views

6 个回答

  • Voted
  1. Best Answer
    plasmid87
    2013-12-04T07:24:23+08:002013-12-04T07:24:23+08:00

    你试过这个吗?

    $ yum list installed bind
    
    • 81
  2. John
    2013-12-04T07:36:42+08:002013-12-04T07:36:42+08:00

    有一个更简单的方法来发出这个查询:rpm -qa | grep bind或rpm -q bind. 如果您不完全确定包名称,则前者是最好的。

    • 22
  3. Fred the Magic Wonder Dog
    2013-12-04T07:27:42+08:002013-12-04T07:27:42+08:00

    解析这个命令的结果是最完整的答案。您需要知道确切的包名称。

    yum info bind
    
    Loaded plugins: refresh-packagekit, rhnplugin
    This system is receiving updates from RHN Classic or RHN Satellite.
    Installed Packages
    Name        : bind
    Arch        : x86_64
    Epoch       : 32
    Version     : 9.8.2
    Release     : 0.17.rc1.el6_4.6
    Size        : 7.3 M
    Repo        : installed
    From repo   : rhel-x86_64-workstation-6
    Summary     : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server
    URL         : http://www.isc.org/products/BIND/
    License     : ISC
    Description : BIND (Berkeley Internet Name Domain) is an implementation of the DNS
            : (Domain Name System) protocols. BIND includes a DNS server (named),
            : which resolves host names to IP addresses; a resolver library
            : (routines for applications to use when interfacing with DNS); and
            : tools for verifying that the DNS server is operating properly.
    
    • 11
  4. domdambrogia
    2017-01-12T10:38:05+08:002017-01-12T10:38:05+08:00

    我想出的最好的一个衬里(这非常适合在脚本中快速使用)是:

    yum info <package_name> | grep Repo | awk '{ print $3 }'
    

    例如:如果我目前已经git安装:

    yum info git | grep Repo | awk '{ print $3 }'
    

    这将返回installed

    如果我目前没有安装git相同的先前命令将返回:base/7/x86_64这是当前可用的安装git

    • 2
  5. Eric Leschinski
    2016-09-02T10:38:38+08:002016-09-02T10:38:38+08:00

    使用 Python 代码检查是否使用 yum 在 python 中安装了一个包:

    def is_installed(package_name):
        return "not installed" in commands.getstatusoutput("rpm -q " + package_name)[1]
    
    • -1
  6. Tom Emerson
    2017-04-27T12:25:50+08:002017-04-27T12:25:50+08:00
    yum list installed bind >/dev/null ; echo $?
    

    如果结果为 0(零),则安装包

    • -2

相关问题

  • 如何从 RHEL 5 迁移到 CentOS 5?

  • yum:两台服务器上的设置相同,结果不同

  • 用于维护 yum 存储库的工具

  • CentOS 的依赖挑战

  • RHEL 5.3 上可用的 yum 存储库

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve