Jeremy  Reilly

Jeremy Reilly


Dig Command in Linux (DNS Lookup)

Dig (Domain Information Groper) is a powerful command-line tool for querying DNS name servers.

The dig command, allows you to query information about various DNS records, including host addresses, mail exchanges, and name servers. It is the most commonly used tool among system administrators for troubleshooting DNS problems because of its flexibility and ease of use.

This tutorial explains how to use the dig utility through practical examples and detailed explanations of the most common dig options.

Installing dig

To check if the dig command is available on your system type:

dig -v

The output should look something like this:

DiG 9.11.3-1ubuntu1.1-Ubuntu

If dig is not present on your system, the command above will print “dig: command not found”. The dig tool can be installed using the distro’s package manager.

Install dig on Ubuntu and Debian

sudo apt update && sudo apt install dnsutils

Install dig on CentOS and Fedora

sudo yum install bind-utils

Install dig on Arch Linux

sudo pacman -S bind-tools

Understanding the dig Output

In its simplest form, when used to query a single host (domain) without any additional options, the dig command is pretty verbose.

In the following example, we’re performing on the domain:


The output should look something like this:

Let’s go section by section and explain the output of the dig command:

  1. The first line of the output prints the installed dig version, and the queried domain name. The second line shows the global options (by default, only cmd).
; <<>> DiG 9.13.3 <<>>
;; global options: +cmd
  1. If you don’t want those lines to be included in the output, use the +nocmd option. This option must be the very first one after the dig command.
  2. The next section includes technical details about the answer received from the requested authority (DNS server). The header shows the opcode (the action performed by dig) and the status of the action. In this example, the status is NOERROR, which means that the requested authority served the query without any issue.
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37159
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 5
  1. This section can be removed using the +nocomments option, which also disables some other section’s headers.
  2. The “OPT” pseudo section is shown only in the newer versions of the dig utility. You can read more about the Extension mechanisms for DNS (EDNS) here .
; EDNS: version: 0, flags:; udp: 4096
  1. To exclude this section from the output, use the +noedns option.
  2. In the “QUESTION” section dig shows the query (question). By default, dig requests the A record.
;			IN	A
  1. You can disable this section using the +noquestion option.
  2. The “ANSWER” section provides us with an answer to our question. As we already mentioned, by default dig will request the A record. Here, we can see that the domain points to the IP address.
;; ANSWER SECTION:		300	IN	A		300	IN	A
  1. Usually, you do not want to turn off the answer, but you can remove this section from the output using the +noanswer option.
  2. The “AUTHORITY” section tells us what server(s) are the authority for answering DNS queries about the queried domain.
  1. You can disable this section of the output using the +noauthority option.
  2. The “ADDITIONAL” section gives us information about the IP addresses of the authoritative DNS servers shown in the authority section.
;; ADDITIONAL SECTION:	84354	IN	A	170762	IN	AAAA	2400:cb00:2049:1::adf5:3ab9	170734	IN	A	170734	IN	AAAA	2400:cb00:2049:1::adf5:3b82
  1. The +noadditional option disables the additional section of a reply.
  2. The last section of the dig output includes statistics about the query.
;; Query time: 58 msec
;; WHEN: Fri Oct 12 11:46:46 CEST 2018
;; MSG SIZE  rcvd: 212
  1. You can disable this part with the +nostats option.


What is GEEK

Buddha Community

Dig Command in Linux (DNS Lookup)

Examples of the dig command in Linux

Dig Command Line Options and Examples
Here is the frequently used command line options and example’s of dig command.
1. Basic Dig Command
A basic dig command accept domain name as command line parameter and prints Address record.
2. Query With Specific DNS Server
The default dig command queries to dns server configured on your system. For example, the Linux systems keep default DNS entry in /etc/resolv.conf.
3. Print Short Answer
Use +short command line option to print result in short form. This is basically useful with the shell scripting and other automation tasks.
4. Print Detailed but Specific Result
Use +noall with +answer to print detailed information but specific. This will print only answer section including few more details as a result.

#linux commands #command #dig #dig command #useful examples #linux

Useful Example for the mv command in Linux

mv Command Examples
Below is the basic mv command examples on Linux terminal.

  • Rename file in current directory – For example rename file source.txt to dest.txt in current directory.
  • Move file to destination directory – Move a source.txt file available in current directory to /tmp directory. In above command the file name is unchanged at target directory. You can also rename file name at destination directory just by providing filename at destination.
  • Move file from source directory to destination directory – We can also move files or directory from some other directory to destination directory.
  • Move multiple files to destination at once – The mv accepts multiple source files and move them to the destination directory at once. The following command will move file1.txt, file2.txt in current directory and /opt/file3.txt to the /tmp directory. Here the last command line parameter is used as destination by the mv command.

#linux commands #command #mv #useful example #mv command #linux

Arvel  Parker

Arvel Parker


Configure DNS over TLS on Linux Mint to Protect DNS Privacy

This tutorial will be showing you how to protect your DNS privacy on Linux Mint with DNS over TLS. We will use a tool called stubby, but first, let me tell you why DNS is not secure.

#linux mint #dns over tls #linux #linux mint desktop #linux mint server #stubby

date command in Linux with Examples

date Command Examples
Show date time in UTC/GMT
View past dates on specific days
View future dates
View date in other timezone
Print date in specific format
View file modification time

#linux commands #command #date #linux

20 Funny Commands of Linux or Linux is Fun in Terminal

1. Command: sl (Steam Locomotive)

2. Command: telnet

3. Command: fortune

4. Command: rev (Reverse)

5. Command: factor

6. Command: script

7. Command: Cowsay

8. Command: yes

9. Command: toilet

10. Command: cmatrix

#linux commands #terminal #funny commands #linux