{"id":1509,"date":"2011-12-19T07:16:50","date_gmt":"2011-12-18T23:16:50","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1509"},"modified":"2023-09-18T15:37:44","modified_gmt":"2023-09-18T15:37:44","slug":"how-to-fix-nslookup-host-dig-bash-command-not-found-in-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-fix-nslookup-host-dig-bash-command-not-found-in-linux\/","title":{"rendered":"How to Fix nslookup, host, dig: -bash: command not found in Linux?"},"content":{"rendered":"<p>When working with DNS tools like nslookup, host, and dig in Linux, you might encounter the error &#8220;-bash: command not found.&#8221; This error typically occurs when the required packages for these tools are not installed on your system. In this guide, we&#8217;ll walk you through the process of installing the necessary packages to fix this issue and enable you to use nslookup, host, and dig commands in Linux.<\/p>\n<pre>\r\n[root@geeks ~]# host -t mx webhostinggeeks.com\r\nbash: host: command not found\r\n[root@geeks ~]# dig -t mx webhostinggeeks.com\r\nbash: dig: command not found\r\n[root@geeks ~]# nslookup -t mx webhostinggeeks.com\r\nbash: nslookup: command not found\r\n<\/pre>\n<p>The goal of this guide is to help you resolve the &#8220;-bash: command not found&#8221; error and ensure that you can use the nslookup, host, and dig commands without any issues.<\/p>\n<h2>Step 1: Install the Required Packages<\/h2>\n<p>The first step to resolve the error is to install the required packages for each command. The packages may vary depending on the Linux distribution you are using.<\/p>\n<p>For Debian-based distributions (e.g., <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a>, Debian), use the following commands:<\/p>\n<ol>\n<li>Open the terminal.<\/li>\n<li>Update the package list by typing:<\/li>\n<\/ol>\n<pre>\r\nsudo apt-get update\r\n<\/pre>\n<ol start=\"3\">\n<li>Install the DNS utilities package by typing:<\/li>\n<\/ol>\n<pre>\r\nsudo apt-get install dnsutils\r\n<\/pre>\n<p>For Red Hat-based distributions (e.g., <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-centos-beginners-guide-centos-linux-distro\/\">CentOS<\/a>, Fedora), use the following commands:<\/p>\n<ol>\n<li>Open the terminal.<\/li>\n<li>Install the bind-utils package by typing:<\/li>\n<\/ol>\n<pre>\r\nsudo yum install bind-utils\r\n<\/pre>\n<p>Or, for more recent Fedora versions:<\/p>\n<pre>\r\nsudo dnf install bind-utils\r\n<\/pre>\n<p>The result should look like this:<\/p>\n<pre>\r\n[root@geeks ~]# yum install bind-utils\r\nSetting up Install Process\r\nSetting up repositories\r\nReading repository metadata in from local files\r\nParsing package install arguments\r\nResolving Dependencies\r\n--> Populating transaction set with selected packages. Please wait.\r\n---> Downloading header for bind-utils to pack into transaction set.\r\nbind-utils-9.3.6-4.P1.el5_4.2.i386.rpm                                      |  43 kB     00:00\r\n---> Package bind-utils.i386 30:9.3.6-4.P1.el5_4.2 set to be updated\r\n--> Running transaction check\r\n\r\nDependencies Resolved\r\n\r\n=============================================================================\r\n Package                 Arch       Version          Repository        Size\r\n=============================================================================\r\nInstalling:\r\n bind-utils              i386       30:9.3.6-4.P1.el5_4.2  rhellocalrepo     170 k\r\n\r\nTransaction Summary\r\n=============================================================================\r\nInstall      1 Package(s)\r\nUpdate       0 Package(s)\r\nRemove       0 Package(s)\r\nTotal download size: 170 k\r\nIs this ok [y\/N]: y\r\nDownloading Packages:\r\nRunning Transaction Test\r\nwarning: bind-utils-9.3.6-4.P1.el5_4.2: Header V3 DSA signature: NOKEY, key ID 37017186\r\nFinished Transaction Test\r\nTransaction Test Succeeded\r\nRunning Transaction\r\n  Installing: bind-utils                   ######################### [1\/1]\r\n\r\nInstalled: bind-utils.i386 30:9.3.6-4.P1.el5_4.2\r\nComplete!\r\n<\/pre>\n<h2>Step 2: Verify the Installation<\/h2>\n<p>After installing the required packages, you should be able to use nslookup, host, and dig commands without encountering the &#8220;-bash: command not found&#8221; error.<\/p>\n<p>To verify the installation, run each command with an example domain or IP address:<\/p>\n<pre>\r\nnslookup webhostinggeeks.com\r\nhost webhostinggeeks.com\r\ndig webhostinggeeks.com\r\n<\/pre>\n<p>If the commands execute successfully and display the DNS information for the specified domain, the issue has been resolved.<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">apt-get<\/span> &#8211; A package management tool used in Debian-based Linux distributions to handle package installation, updates, and removal.<\/li>\n<li><span class=\"fw-bold\">yum<\/span> &#8211; A package management tool used in Red Hat-based Linux distributions to manage RPM packages.<\/li>\n<li><span class=\"fw-bold\">dnf<\/span> &#8211; A package management tool used in recent Fedora distributions, replacing the yum package manager.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>By following this guide, you have successfully fixed the &#8220;-bash: command not found&#8221; error for nslookup, host, and dig commands in Linux. Installing the required packages for your specific Linux distribution allows you to use these essential DNS tools for managing and troubleshooting DNS-related issues.<\/p>\n<p>With these tools now available, you can efficiently perform DNS lookups, test reverse DNS records, and diagnose any domain-related issues that might arise in your network.<\/p>\n<p>We appreciate your feedback, comments, and suggestions for improvements to this guide. Your input helps us deliver the most accurate and useful information possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with DNS tools like nslookup, host, and dig in Linux, you might encounter the error &#8220;-bash: command not found.&#8221; This error typically occurs when the required packages for&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1138],"tags":[1228,1536],"class_list":["post-1509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dns","tag-bind","tag-linux"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1509"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}