dig, short for Domain Information Gopher, is a DNS lookup utility used for probing DNS servers and troubleshooting problems associated with DNS servers. Due to its ease of use, system administrators rely on the tool to troubleshoot DNS issues.
When deploying CentOS 7 Linux minimal in the cloud you may encounter the situation of not finding the dig command on the newly created CentOS 7 server. It returns: -bash: dig: command not found. Therefore, how can we install dig command on CentOS 7 Linux using the command line (bash shell)?
First, you need to log in as root user.
CentOS 7 dig command not found
You may encounter the following error when you run dig command:
$ dig www.mxforge.com $ dig +short myip.opendns.com @resolver1.opendns.com
Try to locate the dig with type command:
$ type -a dig
Display your PATH settings on Linux with help of echo command:
$ echo "$PATH"
Get rid of “-bash: dig: command not found”
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 and tools for verifying that the DNS server is operating properly. However, bind is not installed by default including the dig command.
So you must install bind-utils package. This package consists in a collection of utilities (such as dig command and other) for querying DNS name servers to find out information about internet hosts. All these tools will provide you with the IP addresses for given host names, as well as other information about registered domains and network addresses.
Install dig on CentOS 7
Use yum command to install bind-utilis and get information from DNS name servers:
$ sudo yum install bind-utils
How to use dig command?
dig Hostname dig DomaiNameHere dig @DNS-server-name Hostname dig @DNS-server-name IPAddress dig @DNS-server-name Hostname|IPAddress type
$ dig www.mxforge.com $ dig @220.127.116.11 bash.mxforge.com $ dig @18.104.22.168 MX mxforge.com $ dig @22.214.171.124 AAAA mxforge.com
If you want to find out which package owned dig command on a CentOS Linux 6/7, try:
# yum whatprovides '*bin/dig'
The above command indicates that /usr/bin/dig command provided by bind-utils package.
Now, dig command is installed and working correctly on a CentOS Linux 7. You can use the same command on a CentOS Linux 6.x to install dig command.