how to use whois tools in Linux

How to Use WhoIs Command in Linux

WhoIs is a useful Linux command that allows you to easily get detailed information about domain or website. You can run this command in Linux to lookup information about domain. WhoIs is a listing of domain names and owners. There are many internet companies called registries that hold the data about domain name registration and ownership. Anyone can query this information via ICANN (Internet Corporation for Assigned Names and Numbers) that actually regulates domain name registration and ownership. In this article, we will learn how to use WhoIs command in Linux.

How to Use WhoIs Command in Linux

In this article, we will learn how to use WhoIs command in Linux. Although ICANN regulates all domain registration and ownership, when a person or organization purchases a domain from a domain registrar such as GoDaddy, Namecheap, etc. then the domain’s information starts being maintained by that registrar. When you issue WhoIs command to lookup a domain name, then its registrar responds by returning the information. The whois tool is configured to connect to ICANN & registrars, and get information.

Install WhoIs command

In Ubuntu/Debian systems whois command is already installed. If not, then you can install it via the following command.

$ sudo apt-get install whois

On RHEL/Fedora/CentOS systems, you can install it with the following command.

$ sudo dnf install whois

Using WhoIs with Domain Name

Once WhoIs command is installed, you can use it with a domain name as shown below. Here is an example to use whois command with domain name.

$ whois

Here is the sample output. It contains tons of useful information such as owner, creation date, expiry date, domain status, etc.

Domain Name: CNN.COM
Registry Domain ID: 3269879_DOMAIN_COM-VRSN
Registrar WHOIS Server:
Registrar URL:
Updated Date: 2018-04-10T16:43:38Z
Creation Date: 1993-09-22T04:00:00Z
Registry Expiry Date: 2026-09-21T04:00:00Z
Registrar: CSC Corporate Domains, Inc.

This is really useful to find out details about a specific domain.

Using WhoIs with IP Address

Alternatively, you can also use WhoIs command with an IP address. You just need to specify the IP address after whois command.

$ whois

It pretty much shows the same information displayed above while using whois command with domain name.

Using WhoIs in Shell Script

You can also use WhoIs command in shell script. For example, run the following command to create an empty shell script.

$ vi

Add the following lines in it.



echo "Expiration dates:"

for domain in $DOMAIN_LIST
  echo -n "$domain :: "
  whois $domain | grep 'Expiration' | awk '{print $5}'

In the above code, we store the list of domain names in a space separated manner in DOMAIN_LIST variable. Then we loop through it, one by one, and run whois command for each domain. We pass the output to grep command, and search for the term ‘Expiration’ to retrieve information pertaining to expiration date. We use awk command to display the output.

In this article, we have learnt how to use WhoIs command in Linux. It is a very useful way to get information about a specific domain or IP address. However, if the domain owner has purchased a WhoIs blocker license, then you may not be able to see information about the domain.

Also read:

How to Extract & Copy Files from ISO Image in Linux
Tools to Scan Linux for Viruses & Malware
How to Run Multiple PHP Versions in Apache
How to Run Multiple PHP Versions in NGINX
How to Create & Execute JAR File

Leave a Reply

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