How to Fix ‘bash: dig: command not found’ Error in Linux

Attempting to troubleshoot DNS record propagation, inspect name server responses, or query DNSSEC records by executing dig example.com in a Linux shell only to be met with bash: dig: command not found is a regular hurdle on streamlined distributions and container instances. Because the Domain Information Groper (dig) utility is bundled inside broader network diagnostic toolsets rather than a standalone package matching its command name, entering apt install dig fails with a package not found error. System administrators must install the appropriate distribution package that maintains the BIND utility binaries. Installing the correct diagnostic package restores instant DNS probing.

Install dnsutils via APT on Ubuntu and Debian Distributions

On Debian, Ubuntu, and related distributions, the dig binary is distributed as part of the upstream dnsutils (or bind9-dnsutils) utility suite.

  1. Open your terminal or connect to your remote host via SSH with sudo or root credentials.
  2. Update your local package index to fetch the latest mirror metadata:
    sudo apt update
  3. Install the DNS diagnostic utility package by running:
    sudo apt install -y dnsutils
  4. On newer Debian 12 (Bookworm) and Ubuntu 24.04 LTS installations where the package was rebranded, install the updated transitional package if prompted:
    sudo apt install -y bind9-dnsutils
  5. Verify successful installation by checking the dig version:
    dig -v
  6. Execute a test lookup (for instance, dig +short google.com) to verify that nameserver queries return IP addresses cleanly.

Install bind-utils via DNF and YUM on RHEL, Rocky Linux, and Fedora

Red Hat Enterprise Linux, Rocky Linux, AlmaLinux, and CentOS environments distribute dig inside the bind-utils package architecture.

  1. In your shell session, refresh package cache metadata:
    sudo dnf check-update (or sudo yum check-update on CentOS 7).
  2. Install the BIND utilities package by executing:
    sudo dnf install -y bind-utils
  3. If running inside an unprivileged Docker container where sudo is unavailable, execute the installation as root:
    dnf install -y bind-utils
  4. Verify that the binary path is correctly mapped to your shell environment by typing:
    which dig (which should output /usr/bin/dig).

Install bind-tools via APK on Alpine Linux Docker Environments

Micro-containers running Alpine Linux require the bind-tools package to provide dig, nslookup, and host commands.

  1. Enter your Alpine container interactive shell:
    docker exec -it <container_name> /bin/sh
  2. Synchronise the package repository index:
    apk update
  3. Install the required BIND networking tools:
    apk add bind-tools
  4. Execute dig @8.8.8.8 example.com to perform raw DNS resolution checks within the lightweight container runtime.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.