Sunday, October 9, 2016

How to Block any website in MAC Os or linux

To be more productive some time you may want to block some website.  In my case sometimes I block amazon.com, amazon.in, facebook.com.
To block  website you need to edit your host file
go to terminal and type 
sudo vi /etc/hosts
It will ask for your password

in hosts file add the following line
127.0.0.1   www.facebook.com
127.0.0.1   www.amazon.com

you can add as many as you want to your host file. State above example block www.facebook.com and www.amazon.com.

You may find out some time those example not work with out reboot. In this case you need to clear  dns cache

just type following line in terminal to clear cache

dscacheutil -flushcache




No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }