There will be times when you will have to edit the hosts file on your computer or laptop. The reasons could be manifold including a third-part attack. Whatever the reasons, editing hosts file will give you the right to control web browsing and also manage traffic density to any particular websites.
What Are Hosts File?
Hosts files came into existence along with ARPANET. The files were used specifically before DNS to decide hosts names. Hosts files are large data based documents that help with the name resolution within the network.
Microsoft took the decision of storing line hosts file in Windows networking.
This is one reason the hosts file do not change whether they are used in Linux, Windows or OS X. The syntax for the hosts file remains more or less the same across all platforms of Windows. Some hosts files also give loopback various entries. We will use this as an example of how to edit hosts file.
Tips to Edit Hosts File
Firstly, decide upon an appropriate location where the address can be re-directed to. Secondly, decide on the address that requires to be redirected and thirdly, leave a suitable comment. The hosts file will read typically like: 127.0.0.1 localhosts #loopback
Now that the host file is established, let us look at the ways in which it can be edited in different operating systems.
Ubuntu 10.04 and Linux distro give you the freedom to edit the hosts file in the terminal itself. Simply select an editor tool or even the GUI text editor to begin editing the hosts file.
The hosts file for Ubuntu are available in the /etc/folder. This folder can be found in the root of the drive. We will use sudo to first open the file as root and then edit it.
Edit the file so that the Facebook site is redirected into nothing. Save the edited hosts file and try logging into Facebook. You will be redirected to a site that is actually not there!
2. Snow Leopard (OS X 10.6)
Snow leopard also gives you the freedom to edit the hosts file inside the terminal. You can use either your favorite editor or the GUI text editor for editing hosts file.
In case of Snow leopard, the hosts file is similar to the hosts file of Windows. However, it has some text unlike the one in Windows. Let’s redirect Facebook to a non-existent site.
The loopback here is 0.0.0.0. It will take you directly to the Apache test page.
3. Windows 7
In order to edit hosts file in Windows 7, you will have to perform the below given steps.
Type c:\windows\system32\drivers\etc\hosts in the Run Line.
The command will open the notepad and the file. After the notepad is opened you can begin editing the file. For example, let us run a command to block a popular social networking site like Facebook. This is simple. Key in 0.0.0.0 www.facebook.com after # icon.
With this you would have completed the editing for your hosts file. But remember, it is also important to save the edited Hosts file.
Try opening the Facebook homepage now. You will draw a blank. This means that you have successfully managed to block Facebook on your web browser.