How to block Facebook and other domains with the Hosts file in Mac OS X:
This works in all versions of Mac OS X.
- Launch the Terminal, located in /Applications/Utilities/
- At the command line, type: sudo open /etc/hosts
- Enter your administrative password when asked
- TextEdit will now launch with /etc/hosts open, you need to add the following lines to the bottom of the file
127.0.0.1 facebook.com 127.0.0.1 login.facebook.com 127.0.0.1 www.facebook.com
- Each one of those entries must be on it’s own line. Save the file when it’s finished editing
- Now you need to flush the DNS cache for changes to take effect, type the following command in the Terminal: dscacheutil -flushcache
- Try to access facebook, it should no longer work
If you remove the entires from the /etc/hosts file you will be able to access Facebook again as usual.