How to use host command in Linux.

How To Use Host Command.

Follow this article’s guideline to learn how to use hostname command on Linux.

Host is a command line utility that makes it possible for the Linux users to find information about a given host on a network. You can use the host command to lookup the domain’s IP address and name associated with the domain. It is beneficial for the users especially when they are facing network related issues like the system unable to connect to another website or machine.

 

Use of Host Command on Linux

Host command comes with various options to get the specific details but when you simply execute the host command without any flag, you will see different options on the terminal to run the host command.

host

You can use host command as a DNS lookup utility to get different details using various options given below:

To get the IP address of a domain using host command, execute the command using the syntax given below:

host domain_name

Using above syntax, I have found the IP address details of Linuxhint websites:

host nexonhost.com

To get the name of a domain using host command, execute the command using syntax given below:

host IP_Address

Using above syntax, I have found the domain name of username Linuxhint using its IP address:

host XX.XX.XX.XX

To enable the verbose output, execute the command using syntax given below:

host -a domain_name

Using the above syntax, I have executed the following command to enable the verbose:

host -a nexonhost.com

You can also use the host command with -v flag to get the verbose using the syntax given below:

host -v domain_name

To get the verbose for linuxhint, I have executed the command using the above syntax:

host -v nexonhost.com

To get a specific query, use the syntax given below:

host -t [query_type] domain_name

To get the text record of a host, you can execute the command given below:

host -t txt nexonhost.com

To print the SOA record of a host, you can execute the command given below:

host -t SOA nexonhost.com

If you want to get the number which shows how many times a host repeats a query that does not get answered then execute the command using syntax given below:

host -R number domain_name

For example:

host -R 3 nexonhost.com

For further help, you can open host command manual using the following command:

man host

 

Conclusion

In Linux, you can get the details of a domain name by using the host command on the terminal. The host command is very easy to use with a lot of different options which you can use to get specific queries about any host.