Home » What is The Hosts File and How To Edit Them?
Tips & Tricks

What is The Hosts File and How To Edit Them?

If you are not so familiar with advanced computer topics then, the term “Hosts File” may seem surprising to you because of the name. Every computer has a unique file within the operating systems components which plays a crucial role on how you surf the internet onto your computer.

This Post Covers Below-mentioned Topics

What is Hosts File?

In the very simple terms, Hosts File is a configuration file which stores information about a computer over the network. Hosts Files consist of information about the domain name and IP address mapping, i.e. which domain name will be matched to which IP address, and this is where your browser talks with the DNS (Domain Name Server) before loading any web page.

Uses of Hosts File

As we said, as you enter a web address in the address bar of your browser, before opening the actual web page there is a communication between your browser and DNS (Domain Name Server) to decide the exact IP address of the loading page alternatively domain name.

What if we wish to provide the IP address manually?

Hosts File can serve this purpose for us. We can write the domain name and their mapping IP address we would like to locate within the Hosts File. So next time before going to DNS, your browser will read from the Hosts File first.

Location of Hosts File

So far we know what Hosts File is and where it is used, and we have also said that it is found on your computer. So the curiosity is valid regarding the location of Hosts File.

If you are using Windows operating system then Hosts File can be found at:

C/Windows/System32/drivers/etc/hosts

Considering “C” as your system drives, if you have installed your operating system into some other then look accordingly.

If you have Linux OS installed then the path will be:

/etc/hosts

One thing you should note that hosts files don’t have any extension, so you need just to double-click on it to open. Windows users can use any of the text editors like notepad, word pad, etc. to view it.

From the beginning we are talking about the domain name and their IP address and we have said to update it manually using the Hosts File.

But from where I can find the IP address of any domain name so that I can update it in Hosts File?

Follow the steps mentioned ahead to get the IP address of any domain name.

Finding IP Address of Any Domain Name

We will be using the command prompt, ping command to obtain the IP address. Please make sure that you are connected to a working internet before performing this.

Command promptly is by default installed on your computer. Press CTRL+R to open the run utility. Type “cmd” in the search box and press “ENTER”.

hosts_file_1

Command prompt window will be open to the default view. The last line of the view says something like “C:\Users\User name>, where username is the specific username of your computer.

hosts_file_2

Now write “ping domain name” and then Press “ENTER.” It will be something like this:

C:\Users\zainil>ping www.techtricksworld.com then press “ENTER” which will return you IP address as “46.30.211.223”.

hosts_file_3

So easy it was right, next we will move on to edit our Hosts File. If you are visiting Hosts File for the first time, you will see the default entries in the Hosts File, and now it’s time for some tweaking and playing with it.

How to edit hosts file?

How to edit hosts file is the question you would be looking for as I have talked some interesting things about it. But, wait, there are much more things that will make your even more interested in Hosts file.

So you know, what is Hosts File, where it is found, what is the use of it and how to find IP address of a domain name using the ping command from command prompt window.

Now we are heading towards editing the Hosts File which will change the content of Default Hosts File, and entries will be little generic as per our choice.

As we said before hosts file can be opened with any of the text editor utility so most conveniently notepad will be used. This is how your Hosts File looks like upon opening for the first time:

hosts file

This is the format of making entries to hosts file i.e. IP address then domain name. So if we wish to append the IP address of www.tecktricksworld.com, just go to the end of the file and write “46.30.211.223 www.techtricksworld.com”. So next time when you will write the URL of www.techtricksworld.com into your browser, the Hosts File will be read, and the browser will be directed to the mentioned IP address as per the Hosts File.

Believe me, it is fun when you know how to modify Hosts file. You can make your computer access to internet the way you want.

So you know how to edit a Hosts File. Wouldn’t it be fun to try a little hacking using Hosts Files? Better to perform such trick on someone else’s computer to fool them or making them scratching their head for what they are seeing.

How to block websites using Hosts file on a particular Computer?

The trick comes handy if you are a parent and don’t want your children to have access to a particular website. Many offices restrict the access of specific sites for their employees. In that case, the only thing they do is to edit the Hosts File so that when the browser sees the particular domain name it will block it. Let’s see how we can do this.

Go to the location of your Hosts File as per your operating system configuration and open it in notepad preferable to modify the Hosts File. Say you want to block the access of www.facebook.com then go to the end of the Hosts File and write “127.0.0.1 www.facebook.com.” Here if your site is something other than www.facebook.com, then you can add that accordingly. Save and close the Hosts File.

Next time when you write the domain name www.facebook.com in the browser, the website will not be accessible. The same way you can add the multiple domain names in order to block and if you wish to allow the access of that particular website then just remove the domain name from the listing and site will be accessible again.

This is how you can block websites using hosts file on your computer. Isn’t it cool?

Hacking Hosts File

The term hacking is used when we intent to change the actual behavior of something and modify it to happen is some different way.

You can have a custom hosts file on your PC to make your computer work your way.

Suppose as a prank on your friend’s computer you can modify the Hosts File so that upon typing www.google.com it should redirect to www.techtricksworld.com.

Isn’t it will be fun to see the reaction of your friend on this? I hope you very well know now, how to achieve that.

We just need to open the Hosts File normally and writing IP address of www.techtricksworld.com ahead of domain name www.google.com will work our purpose. So next time when www.google.com is typed in the browser, browser will read the Hosts File and upon seeing the IP address, it will automatically direct the user to www.techtricksworld.com

Wrapping up

So this is for now on the Hosts Files, what it is, where it is located, how to edit hosts file, how to play with them regarding some sort of hacking stuff. There is much more to explore where you can have more fun with and amaze your friends with the tricks.

Happy Learning!

About the author

Zainil Dedhia

Zainil is commerce graduate & is pursuing his further studies in commerce. He loves to write about software's & social media.

Connect with Zainil: Facebook and Twitter.

9 Comments

Click here to post a comment

All the data shown above will be stored by Techtricksworld.com on https://www.techtricksworld.com. At any point of time, you can contact us and select the data you wish to anonymise or delete so it cannot be linked to your email address any longer. When your data is anonymised or deleted, you will receive an email confirmation. We also use cookies and/or similar technologies to analyse customer behaviour, administer the website, track users' movements, and to collect information about users. This is done in order to personalise and enhance your experience with us.

  • Hey Zainil,

    It’s good to know that people can edit the host files. I have never thought about it before. The way you have mentioned is clear.

    I am sure there are many people who are seeking for the right information.
    Thanks for sharing with us.
    Enjoy the day.
    ~Ravi

  • Hi Zainil,
    Yet another informative piece.
    Thank you so much for sharing this.
    As said, I am not aware of this host file editing thing.
    This is really a wonderful information you shared,
    the step by step guide is indeed easy to do.
    Thanks again for the share. 🙂
    May you have a great and profitable time ahead.
    Best
    ~ Philip

  • Hi Zainil Dedhia,
    That’s amazing knowledge about host File, basically I have used many times host file to block any software registration, but today I have learned new on host file. Thank You Very Much.

Pin It on Pinterest