88

I keep getting answers like:

yum list installed | grep bind

or

rpm -qa | grep bind

But that is not accurate as I'm getting a list of few other bind packages like these:

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

That is not I wanted. Instead I would want to accurately check if bind core package has been installed. Eg. bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6

I was hoping for something like:

yum check installed bind

But hopefully someone could shed the light.

Randall
  • 339
  • 3
  • 18
checksum
  • 1,085

6 Answers6

94

Have you tried this?

$ yum list installed bind
plasmid87
  • 2,118
26

There's a much easier way of issuing this query: rpm -qa | grep bind or rpm -q bind. The former is best if you're not completely sure of the package name.

John
  • 9,208
  • 1
  • 32
  • 34
11

Parsing the results of this command is the most complete answer. You'll need to know the exact package name.

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.
3

The best one liner I've come up with to do this (which is great for using quickly in scripts) is:

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

For example: if I currently have git installed:

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

This will return installed

If I currently don't have git installed that same previous command will return: base/7/x86_64 which is the current available installation for git

-1

Use Python code to check if a package is installed in python using yum:

def is_installed(package_name):
    return "not installed" in commands.getstatusoutput("rpm -q " + package_name)[1]
-2
yum list installed bind >/dev/null ; echo $?

If the result is 0 (zero) the package is installed

chicks
  • 3,915
  • 10
  • 29
  • 37