Debian 9 dig command not found – How to install dig on Debian

I deployed Debian 9 Linux minimal deployed in the cloud. However, I am unable to find the dig command on my newly created Debian 9 server. It says ‘-bash: dig: command not found‘ I tried apt install dig, but it failed. How do I install dig command on Debian 9 Linux using the command line?

Introduction: The dig command is primarily used to query DNS servers. It is a useful tool for network troubleshooting. It is popular due to its flexibility, simple to use, and crystal clear output over host command. This page shows how to install dig command on a Debian 9 using the bash shell. You must log in as root user to install the following package.


Debian 9 dig command not found

You may get the following error when you run dig command:
vivek@debina9:~$ dig
vivek@debina9:~$ dig +short

Try to locate the dig with type command:
vivek@debina9:~$ type -a dig
Display your PATH settings on Linux with help of echo command:
vivek@debina9:~$ echo "$PATH"
Debian 9 dig command not found

Getting rid of “-bash: dig: command not found” on Debian 9

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.

You must install dnsutils package. It contains a collection of utilities (such as dig command and other) for querying DNS name servers to find out information about internet hosts. These tools will provide you with the IP addresses for given host names, as well as other information about registered domains and network addresses.

How to install dig on Debian 9

You must install dnsutils if you need to get information from DNS name servers. Use the apt command or apt-get command:
vivek@debina9:~$ sudo apt install dnsutils
How to install dig on Debian Linux 9 using apt-get command

How do I use dig command?

The syntax is:
dig Hostname
dig DomaiNameHere
dig @DNS-server-name Hostname
dig @DNS-server-name IPAddress
dig @DNS-server-name Hostname|IPAddress type

For example:
vivek@debina9:~$ dig
vivek@debina9:~$ dig @
vivek@debina9:~$ dig @ MX
vivek@debina9:~$ dig @ AAAA

dig command installed on a CentOS Linux 7 and displaying dns output of a query

dig command installed on a CentOS Linux 7 and displaying dns output of a query

A tip about finding package names on Debian 9

Want to find out which package owned dig command on a Debian 9 Linux 6/7? Try:
vivek@debina9:~$ apt-cache search dns dig
Find out which package provides dig command on Debian Linux
The above command indicates that /usr/bin/dig command provided by dnsutils package on a Debian Linux version 8/9.


And there you have it, dig command installed and working correctly on a Debian Linux 9 or earlier versions. You can use the same command on a Debian 8 to install dig command.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.