Ubuntu dig command not found – How to install dig on Ubuntu nixCraft

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

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 Ubuntu using the bash shell. You must log in as root user to install the following package.

Ubuntu dig command not found

Please note that vivek@nixcraft-asus:~$ is the shell prompt. The shell prompt normally ends in a $ sign. So type all commands after vivek@nixcraft-asus:~$

You may get the following error when you run dig command:
vivek@nixcraft-asus:~$ dig www.cyberciti.biz
vivek@nixcraft-asus:~$ dig +short myip.opendns.com @resolver1.opendns.com

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

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

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 on an Ubuntu based system. 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 Ubuntu Linux

You must install dnsutils if you need to get information from DNS name servers. Use the apt command or apt-get command:
vivek@nixcraft-asus:~$ sudo apt update
vivek@nixcraft-asus:~$ sudo apt install dnsutils

How to install dig on Ubuntu Linux using apt-get command

How do I use dig command on Ubuntu?

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

For example:
vivek@nixcraft-asus:~$ dig www.cyberciti.biz
vivek@nixcraft-asus:~$ dig @ bash.cyberciti.biz
vivek@nixcraft-asus:~$ dig @ MX cyberciti.biz
vivek@nixcraft-asus:~$ dig @ AAAA cyberciti.biz

dig command installed on an Ubuntu Linux and displaying dns output of a query
dig command installed on an Ubuntu Linux and displaying dns output of a query

A tip about finding package names on Ubuntu

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


And there you have it, dig command installed and working correctly on a Ubuntu. You can use the same command on a Ubuntu 16.04 or earlier or latest version to install dig command.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Facebook Comments

More Stuff

Don’t be fooled by Pass4Sure Today I received an enquiry sent via my contact page, offering me US$175 if I place some advertising on my site in a certain way. Here’s the full text...
Why containers are the best way to test software performance Software performance and scalability are frequent topics when we talk about application development. A big reason for that is an application's perform...
A 4-step plan for creating teams that aren't afraid to fail Successfully executing on a business goal implies raising questions about that goal—and it absolutely requires safe-to-fail experimentation on the pat...
Finding alternatives to proprietary online tools with Framasoft You can’t escape Google. At least, that’s how it seems. The company doesn’t just dominate search. It also has its tendrils in personal storage, online...
Spread the love

Posted by News Monkey