To edit the hosts file and add a new blocking entry, open up your Terminal and type the following (You’ll be asked for your root password because this is a system file):
sudo nano /etc/hosts
This will bring up a Nano box that looks like the one below. Yahoo has been added to block list as you can see. To block any other site, simply type it in the same format.
Note: one line, one site. And don’t forget to add “www” if the URL has been prefixed with “www”, or it will not work with Safari.
Click CTRL+X and Press Y in your keyboard to save modified buffer, and then press Enter to go back to Terminal.
Please run the following command in Terminal to take the changes take into effect:
- 1. If you are using Tiger, please type the following and press Enter:lookupd –flushcache
2. For Mac OS X 10.5 and later, please type the following and press Enter:sudo dscacheutil –flushcache
Now the web site has been successfully blocked on your Mac
2. Use a third-party blocking tool.
By modifying the Hosts file we can block any sites we want to on Mac. But we do not suggest it when you are not Mac savvy enough. There is an easy alternative for you: using a third-party blocker. They are mostly be used as parental blocking. Take a look at Parental Control Software webpage which introduces a lot about parental blocking and monitoring tool for Mac and Windows.