• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
  • VPS
    • VPS Hosting
    • Flex VPS
  • Reseller
  • Email
  • Gaming
  • Domains
  • Website Builder
  • Account
  • Blog Home
  • Categories
  • Authors

Using the “whois” Command – All you Need to Know

Bhagwad Park

Published on: April 16, 2025

Categories: Linux Command Line, VPS Hosting 0

The “whois” command is very well-known in programming circles. The website whois.com is pretty well-known, even though it’s not accredited with ICANN. Using whois, you can find out everything you need to know about a domain – who owns it, when it expires, its status, nameservers, and even the contact information of the owners. In this tutorial, we’ll explore the uses of the whois command, why you would want to use it, and what advantages you have using the whois command vs just going to a website and pulling the information yourself.

  • Using the Whois Command
    • Registry vs Registrar
  • Why Not Use Websites Instead of “Whois”?
    • Faster Repeated Lookups
    • Unfiltered Data
  • Conclusion

Using the Whois Command

The whois command queries databases containing domain data. We’d previously seen how to use dig to specify a DNS server, and in that article, we saw that there are a few “authoritative” nameservers that you can use to directly resolve domain names most authoritatively. But just like most of the time, the dig or “ping” command queries the most convenient nameservers, the whois command also doesn’t query the most authoritative server. Instead, it queries a server that can refer you to the authoritative server.

For example, consider the following whois command:

whois bhagwad.com

This generates the following output:

Basic whois Command

You can see that we get all the details of the domain. Who the registrar is, when it was created and updated, the nameservers, and the e-mails you need to contact in order to report abuse.

But the data from the whois command is a lot more than just this. I can’t show you everything because of space constraints, but you can see that it queries the VeriSign servers from this screenshot:

Querying Verisign

The reason the tool queries VeriSign is that the VeriSign registry handles all .com and .net domains. Here’s a breakdown of the other registries that handle other domain types:

whois.verisign-grs.com	.com and .net domains
whois.publicinterestregistry.org .org domains
whois.nic.io .io domains
whois.arin.net IP addresses in North America
whois.ripe.net IPs in Europe, Middle East, parts of Asia
whois.apnic.net IPs in Asia Pacific
whois.lacnic.net IPs in Latin America
whois.afrinic.net IPs in Africa
whois.iana.org Metadata about TLDs and IP blocks

So, each domain type goes to a different whois server.

Registry vs Registrar

These servers can then refer you to another server that provides the whois information. For example, in the above example, you can see the following line:

Registrar WHOIS Server: whois.cloudflare.com

In this, VeriSign is sending the whois tool to Cloudflare for further information. Buy why? If Verisign already knows everything, why is it redirecting us to Cloudflare? The reason is that VeriSign is the registry, and Cloudflare is the registrar. This means that VeriSign knows where the information is found, but doesn’t carry that information itself. It’s simply saying, “Yes, this domain exists, the registrar is Cloudflare, and here is the Cloudflare whois server”. The whois command sees this line and then queries the Cloudflare server directly for accurate information.

This architecture is mandated by ICANN. It ensures that a single entity doesn’t fully control all the data. It keeps information scalably distributed across the globe.

Why Not Use Websites Instead of “Whois”?

You might be aware of websites like whois.com, or even the ICANN-affiliated https://lookup.icann.org/en, which can give you all the information you need. So why would you bother with using a separate tool like the whois command when you can just go to a browser and get the information yourself, like this?

ICANN whois Lookup Website

For regular usage, the ICANN website lookup is indeed the best option. You don’t need to know anything about the command line, and you can just load the address in your browser, type in the domain name, and you’re good to go. The question then becomes – why would you choose to use the command line instead?

Here are some benefits to using the command line “whois” command, instead of checking it from a website.

Faster Repeated Lookups

While looking up whois data on websites is great for the occasional one-off retrieval, it becomes a lot more complicated if you have a lot of domain names for which you need information. Many websites have restrictions on the number of requests you can make in a given time, not to mention the annoyance of seeing unrelated content like ads, etc.

And because the website needs to load the entire HTML, etc, the process is slow. It’s fine for the single odd domain, but as soon as you need more, it’s impractical. Many websites even require you to pass a CAPTCHA, and depending on the complexity, this will add a delay for every additional lookup. For such situations, the whois command is perfect.

Simply typing:

whois bhagwad.com

It will give me all the information I need about my website without any additional barriers. I can even use bash scripting to parse the output of several domains at the same time. For example, let’s say I have a file called “domains.txt” with a list of domains like this:

example.com
bhagwad.com
somefakedomain12345.com

Now let’s say I want to see which of these domains is available for purchase. That means it shouldn’t be in a “renewed” status, or something similar. I can use the following bash script:

#!/bin/bash

while read domain; do
status=$(whois "$domain" 2>/dev/null | grep -iE 'Domain Status|Status' | awk -F: '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' | paste -sd ', ')

if [[ -z "$status" ]]; then
echo "$domain : [NO STATUS FOUND or AVAILABLE]"
else
echo "$domain : $status"
fi
done < domains.txt

Paste the above code into a file called “domainscheck.sh”, for example, and follow the instructions in my earlier tutorial on how to run sh files in Linux. Now, executing this file gives the following output:

Getting the Status of Domains

As you can see, I’ve created the script file and given it execution permissions. Now, when I run it, I get a neat list of the status of each of the domains. In the above screenshot, only the last one is available for purchase – hardly surprising, since it’s a made-up domain that no one would use!

You can see how convenient the above script would be if you had a text file with hundreds of domains whose expiry you needed to check!

Unfiltered Data

When you look up the domain data through a website, they don’t give you the raw, unfiltered output that the whois command will. Instead, they format it according to what they think you will find most useful. Because of this, you might not get everything you’re looking for, particularly if you want to dig more deeply into the domain. Some websites, like the one run by ICANN, also give you the unfiltered output in the form of a JSON data structure, but you need to know how to read it, and it’s located at the very bottom.

Still, if it’s just the odd domain that you want to look up, it’s easier than using the whois command.

Conclusion

The whois command is a very useful tool for getting detailed information about a domain. Without it, you would have to go to a 3rd party website for the information, which could take a lot of time, particularly if you have many domains to look up. With the whois command, you get the raw, unfiltered output, and you can use scripting to get it in exactly the format you want.

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Yum vs. Dnf: All You Need To Know

Here's the difference between yum and dnf, along with suggestions on which one you should use. Should you switch?

Install Pip3 On Ubuntu: The Ultimate Guide

Check out our beginner friendly guide on how to install and setup pip3 on Ubuntu. Simple copy and paste the commands and you're off!

OpenSSL Version: How To Check

Learn how to check your OpenSSL version and everything else you need to know about OpenSSL including how to create on and set it up!

Fixing “the following packages have been kept back” Ubuntu Error

The error "the following packages have been kept back" occurs when Ubuntu is unable to upgrade packages for various reasons.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup (2024)

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Email Hosting
  • Game Hosting
  • Domains
  • Website Builder
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2025 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA