How to Fix bash host command not found in Minimal Linux

The host command is a simple, lightweight utility for performing Domain Name System (DNS) lookups, translating human-readable hostnames into IP addresses and vice versa. However, when working in stripped-down Linux installations, minimal virtual machine appliances, or lightweight container base images (such as Ubuntu, Debian, or Alpine), attempting to run the command often results in the error: bash: host: command not found. Because minimal server images exclude optional networking diagnostics to conserve disk space, the utility must be provisioned via your package manager.

Install host on Debian, Ubuntu, and Linux Mint

On Debian-based distributions, the host binary is provided by the bind9-host package:

  1. Update your local package index:
    sudo apt update
  2. Install the bind9-host package:
    sudo apt install -y bind9-host
  3. Alternatively, if you require a full suite of DNS lookup tools (including dig and nslookup), install dnsutils:
    sudo apt install -y dnsutils
  4. Verify installation by performing a test resolution:
    host google.com

Install host on RHEL, CentOS, Rocky Linux, and Fedora

Enterprise Linux distributions bundle the host command inside the bind-utils package:

  1. On Fedora, Rocky Linux, AlmaLinux, or RHEL:
    sudo dnf install -y bind-utils
  2. On legacy CentOS 7 servers:
    sudo yum install -y bind-utils
  3. Confirm that the binary is available in your PATH:
    which host

Install host in Minimal Alpine Linux Containers

Alpine Linux containers provide the BIND host lookup tool through APK:

  1. Update the package database:
    apk update
  2. Install the bind-tools package:
    apk add bind-tools
  3. Test DNS resolution:
    host -t A cloudflare.com
  4. In automated Dockerfile recipes, append the package to the installation layer:
    RUN apk add --no-cache bind-tools

Perform Basic DNS Lookups Using host

Once installed, host offers rapid diagnostics for DNS record verification:

  • Query Mail Exchange (MX) records:
    host -t MX example.com
  • Perform reverse DNS (PTR) lookup on an IP address:
    host 8.8.8.8
  • Query against a specific nameserver:
    host example.com 1.1.1.1

Installing the bind9-host or bind-utils package restores instant DNS diagnostics and resolves the “command not found” error across minimal Linux systems.

Get the best tech tips delivered straight to your inbox.

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