Monday, 25 May 2015

Modify Host file to Block Specific Website(s) on Different OS's


What is Host File?

The Hosts file is is used by OS to map host names to IP addresses. It is located deep down in the Windows folder.

In this article, I will show how to modify a host file to block website(s) on the computer with different OS's;
  • Windows
  • Linux
  • Mac OS

Windows:

In Windows, you are needed to open up the hosts files as an Adminsitrator.
1. Open Notepad as Administrator (otherwise file can not be modified);




2. Now select File and click Open then go to the location as per your OS;


Locations as per OS:
  • Windows 95/98/Me: C:\Windows\
  • Windows NT/2000/XP: C:\Winnt\System32\drivers\etc\ or C:\Windows\System32\drivers\etc\
  • Windows XP Home/Vista/Windows 7: C:\Windows\System32\drivers\etc\
  • Windows 8/8.1: C:\Windows\System32\drivers\etc\


3. Now, we need to open our hosts file, as the Host file is not a standard host file so it will not show by default, you have to change the File Type from Text Documents(*.txt) to All Files so it will be visible and then open the hosts file;




4. Be sure to make a backup of your hosts file in case if you will do anything wrong. As the hosts file will get open, edit the file with the site which you want to block, add the website just below the last # with the IP Address 0.0.0.0 so that it will get directed nowhere, i have added only single site but you can add multiple sites, one website with IP Address in per line;



4. Now press Crtl + s to save the file, and check if your entered site is running or not, in the screenshot below that it is blocked, you can revert the changes to make it working again.


Ubuntu (Linux):
In Ubuntu and many other Linux distro’s hosts file can be directly edited in the terminal. Like Windows in which file is needed to be opened as Administrator, now in Linux file is needed to be opened as root so the sudo is used to file the file as root.



1. Open up the terminal and enter the command sudo vim /etc/hosts/



Locations as per OS:
  •  Linux/Unix: /etc/hosts

2. Be sure to make a backup of your hosts file in case if you will do anything wrong. As the hosts file will get open, edit the file with the site which you want to block, add the website with the IP Address 0.0.0.0 so that it will get directed nowhere, i have added only single site but you can add multiple sites, one website with IP Address in per line, I have edited it to redirect Facebook into nothing;



3. Now press Crtl + s to save the file, and check if your entered site is running or not, in the screenshot below that it is blocked, you can revert the changes to make it working again.


Mac OS:
Accessing the hosts file in Mac OS is very similar to Ubuntu.

1. Open up the terminal(Applications -> Utilities -> Terminal) and enter the command sudo vim /private/etc/hosts/

Its will ask for a user password, enter it.



Locations as per OS:
  •  Mac OS(all versions): /private/etc/hosts/

2. Be sure to make a backup of your hosts file in case if you will do anything wrong. As the hosts file will get open, edit the file with the site which you want to block, add the website with the IP Address 0.0.0.0 so that it will get directed nowhere, i have added only single site but you can add multiple sites, one website with IP Address in per line, I have edited it to redirect Yahoo into nothing;


3. When you are done, press Control + O to save the file and return to accept the file name, Exit the editor by pressing Control + X. This takes you back to the terminal screen and check if your entered site is running or not, in the screenshot below that it is blocked, you can revert the changes to make it working again.



Its all done now.

Note: Do Not Use Any Tutorial Of This Blog To Harm Anyone. This Is Only For Educational Purpose. I Will Not Be Responsible For Anything Done By You.



Do you my like Articles..?

Get Free Email Updates Daily!

Follow us!

Categories:

0 comments:

Post a Comment

Please Comment Here To Inform Us Your Review About It. Thank You