The short answer

dig sends one DNS query and prints the whole reply: the response code, the header flags, every section of the message and how long it took. That detail is why it is the standard tool for DNS troubleshooting. It ships with BIND and is installed by default on most Linux distributions and on macOS; on Windows it comes with the BIND tools or WSL.

dig [@server] name [type] [+options]

With no server, dig uses the resolvers in /etc/resolv.conf. With no type, it asks for A.

Reading the output

$ dig @1.1.1.1 example.com A

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4721
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232

;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            172     IN      A       23.192.228.80
example.com.            172     IN      A       23.215.0.136

;; Query time: 12 msec
;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)
PartWhat it tells you
statusThe response code: NOERROR, NXDOMAIN, SERVFAIL, REFUSED. See DNS response codes.
aa flagThe answer came from an authoritative server for the zone
rd / raRecursion was requested / is available: you are talking to a resolver
ad flagThe resolver validated the answer with DNSSEC
tc flagThe reply was truncated; dig retries over TCP unless told not to
OPT pseudosectionEDNS details: the UDP buffer size and, on errors, any Extended DNS Error code
TTL columnSeconds left in cache (from a resolver) or the full TTL (from an authoritative server)
AUTHORITY sectionName servers for a referral, or the SOA on a negative answer

The addresses shown are an example; run the command to see current values.

Options worth knowing

OptionUse
+shortPrint only the answer data
+noall +answerPrint only the answer section, with names and TTLs
+norecurseDo not ask for recursion; use when querying an authoritative server
+traceFollow referrals from the root yourself and print each step
+dnssecSet the DO bit and show RRSIG records
+cdAsk the resolver not to validate; compare with a normal query to spot DNSSEC failures
+tcpUse TCP instead of UDP
+bufsize=NSet the advertised EDNS UDP size
+nsidAsk the server to identify itself, useful behind anycast
-x 192.0.2.10Reverse lookup (PTR) for an address
-4 / -6Send the query over IPv4 or IPv6 only
+httpsSend the query over DNS over HTTPS (BIND 9.18 and later)

Common recipes

QuestionCommand
What does the zone itself say?dig +norecurse @ns1.example.net example.com A
Which servers is the domain delegated to?dig +norecurse @a.gtld-servers.net example.com NS
Do all name servers have the same zone?dig +nssearch example.com
Is DNSSEC the reason for a SERVFAIL?dig @1.1.1.1 +cd example.com A
What is the DMARC policy?dig +short _dmarc.example.com TXT

For a side-by-side with Windows' built-in tool, see nslookup vs dig.

How DNS Panopticon helps

Domain Visualizer runs the lookups you would otherwise type one by one (A, AAAA, NS, SOA, MX, TXT, CAA, DS, DNSKEY and the mail policy records) through a public resolver and lists the records it got back, with TTLs. Use dig when you need to ask a specific authoritative server, follow a trace, or test UDP and TCP, which Visualizer does not do.

Sources and further reading