Uninstall dig command in centos 6?

There are 2 methods for installing and removing packages on Red Hat based distros such as CentOS, Fedora, or RHEL. Often times newcomers are confused by what looks to be duplicate commands but these 2 commands are complimentary and should be used as follows.

When installing & removing packages you should 95% of the time use yum to do the heavy lifting. So to install a package:

$ yum install <package>

To remove a package:

$ yum remove <package>

So then the question becomes, what package does a given file belong to? To determine this you can use the command type to programmatically figure this out.

$ type -p dig
/usr/bin/dig

To determine what RPM package a given file belongs to you can use rpm to query the system's RPM database like so for this:

$ rpm -qf /usr/bin/dig
bind-utils-9.3.6-20.P1.el5_8.6

So you can get fancy and do the type command along with the rpm command in a one liner like this:

$ rpm -qf $(type -p dig)
bind-utils-9.3.6-20.P1.el5_8.6

So why can't I just use RPM to install and remove?

It's true that you can make use of rpm's erase switch, -e to remove a package but I often encourage new comers to use yum because yum has a more high level perspective of the system and can determine if the removal of a given package will impact other packages, and yum can also remove other unnecessary packages when you direct it to remove a given package if they're no longer required.

NOTE So the bottom line is yum is just smarter about package management then rpm.

Is removing these a "good thing"?

Since this packages was optionally installed after your system was setup/installed its removal is not a big deal. However I'd caution you about removing packages that you don't fully understand their role, especially packages such as this one where there are several tools included, and not just one.

Often times there are a suite of command line tools that are included in a package that will typically go unused, meanwhile some other tool in the suite is used either by you constantly or by other tools/scripts/cronjobs constantly.

The removal of such tools can lead to annoying breakages for you and generally just wastes your time, so I'd encourage you to just leave these packages installed.


yum is "just" a package manager over the rpm package system. So if you want to remove an installed package yum remove is the answer (or in some extreme cases rpm -e).

To get the complete name of the package owning the dig command (the package version is just an example from a CentOS 5.8):

$ rpm -qf $(type -p dig)
bind-utils-9.3.6-20.P1.el5

Then you can remove this package using:

$ yum remove bind-utils-9.3.6-20.P1.el5

If you want to known more about rpm or yum: man rpm or man yum.

WARNING: If not mandatory, this package still contains some very useful DNS related utilities like host:

$ rpm -ql bind-utils-9.3.6-20.P1.el5
/usr/bin/dig
/usr/bin/host
/usr/bin/nslookup
/usr/bin/nsupdate
/usr/share/man/man1/dig.1.gz
/usr/share/man/man1/host.1.gz
/usr/share/man/man1/nslookup.1.gz
/usr/share/man/man1/nsupdate.1.gz