703Blocking hosts in /etc/hosts

How to block access to websites on your personal computer. The /etc/hosts file maintains a records of redirects, it you want to block access to a particular site, redirect to your local machine, or whichever site you find appropriate. Not that most website forward host-to-block.net to www.host-to-block.net, so make sure to block the www site as well.

Open the file in your favourite text editor, make sure you have the permissions to open it.

sudo nano /etc/hosts

Add the following line to the file.

127.0.0.1       host-to-block.net
127.0.0.1       www.host-to-block.net

Flush the cache to make the changes immediate.

sudo dscacheutil -flushcache

Again. The crucial bit is to also block the www-site. That seems to be missing from a lot of descriptions/tutorials out there in the wild.