Command library / dig
dig
Query DNS records for a domain
dig (Domain Information Groper) sends a DNS query and prints the answer. The domain name comes first; the record type (A, MX, NS, TXT…) is an optional second word — dig recognises it by matching known type names, not by a flag. `+short` trims the output to just the answer, and `@server` sends the query to a specific DNS server instead of your default resolver.
Practice digUsage
dig +short name
Options and flags
namethe domain name to query
typerecord type: A, MX, NS, TXT, CNAME, AAAA… (default: A)
Examples
dig example.comThe A record (IPv4 address) for example.com — the default query.
dig example.com MXWhich mail servers handle email for this domain.
dig +short example.comJust the answer, none of dig's normal header/footer noise.
dig @8.8.8.8 example.comAsk Google's resolver directly instead of your system's default — useful when you suspect local DNS is lying to you.
Common mistakes
The name comes before the type, not after — dig reads left to right and the type is recognised by keyword, wherever it lands, but conventional order is name then type.