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"
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 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 @1.1.1.1 bash.cyberciti.biz
vivek@nixcraft-asus:~$ dig @1.1.1.1 MX cyberciti.biz
vivek@nixcraft-asus:~$ dig @1.1.1.1 AAAA cyberciti.biz
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
The above command indicates that /usr/bin/dig command provided by dnsutils package on an Ubuntu Linux.
Conclusion
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.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |