The hosts file is a computer file used in an operating system to map hostnames to IP addresses. The hosts file is a plain-text file and is conventionally named hosts. (This file has no file name extension, it’s simply called hosts).
You can use a hosts file to block ads, banners, malware or specific websites like in this guide. This is accomplished by blocking the connection to these websites or files (specifically by redirecting any connection attempts back to the local (your) machine.)
Location of the hosts file
This guide will assume you are on a Windows OS. The easiest ways to locate the hosts file is to open the Run dialog (Windows button + R) or simply use the search box in Windows 7.
Type %SystemRoot%\system32\drivers\etc\ and press enter
Editing the hosts file
You will now be in the folder containing the hosts file.
Before you continue, make a backup of the hosts file by first selecting it, copying (CTRL + C) and pasting (CTRL + V) it in the same folder.
Now we want to edit it. Right click it and select Open, select Notepad and press OK.
We are now editing the hosts file. Find the part where it looks like the following:
and add this:
It should look like this now:
127.0.0.1 localhost 127.0.0.1 www.facebook.com 127.0.0.1 facebook.com
Save the file and exit. Facebook is now blocked, enjoy your new found productivity!