How to install and use the ‘dig’ command on Debian/Ubuntu


dig (domain information groper) is invaluable for name resolution queries. Although you could also use nslookup, dig just feels more modern and snappier.

This guide shows some common use cases for dig.

How to determine which name servers a domain is using

dig +short @ NS

How to get the serial number with dig

dig +multi soa | grep 'serial'
dig +short soa

+short is useful because it suppresses the huge amount of output dig provides.

Always Using +Short

One catch with dig is sheer overwhelming amount of output it produces. Sometimes it’s better to always use dig with the +short option so that you can only see relevant output. To enable dig to always produce the abbreviated output, add this Bash shell alias:

alias dig="dig +short"

To unset it again:

unalias dig


On some Ubuntu minimal installations the dig command won’t be installed by default. This means you will be unable to perform name resolution troubleshooting. Dig is part of ‘dnsutils’ so you can install it like so:

sudo apt-get install dnsutils


Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top