How To Block Websites on Your Mac Using Terminal

Your ads will be inserted here by

Google Adsense.

Please go to the plugin admin page to set up your ad code.

terminal icon new

One of the greatest time wasters today has got to be social-networking websites. More specifically, Facebook and Twitter. I found myself spending unnecessary amounts of time on both of those websites during work or when I had nothing else to do. Let’s not lie, it’s an addiction, and many people are guilty of it besides me. Fortunately, there have already been temporary solutions such as SelfControl, a  freeware application developed by Steve Lambert. In the past I used SelfControl because it was simple and allowed me to setup a time frame that I could block out Facebook and/or Twitter. For students, I can almost certainly recommend using that application during finals week or when preparing for any exams in general. However, I wanted to stop frequenting Facebook on my Mac, so I needed a more permanent solution other than deactivating my account because I still want to be able to access Facebook from my iPhone. With a view commands in Terminal, this can be done in no time!

  1. Open up Terminal in /Applications/Utilities.
  2. In the command line, type in "sudo nano /etc/hosts".
  3. When asked, type your admin password.
  4. In the screen that will appear, you’ll see the host database for your computer.
  5. Using your down arrow, go to the bottom, right under where it says, "127.0.0.1 localhost".
  6. Type in "127.0.0.1 facebook.com".
  7. On a new line, type in "127.0.0.1 www.facebook.com"; this is for extra measure.
  8. Now, hold down Control + “O”. This will save the changes to the host database.
  9. Hit “Return” and then Control + “X” to exit the screen.
  10. Remove the existing cache by typing in "sudo dscacheutil -flushcache" in the command line, this refreshes the existing cache on the host database.
  11. You should receive an “Unable to connect” error message when you go to Facebook.com now.
  12. Now, back to doing something more productive…

Your ads will be inserted here by

Google Adsense.

Please go to the plugin admin page to set up your ad code.

screenshots: 1 2-3 4-7 10 11

Your ads will be inserted here by

Google Adsense.

Please go to the plugin admin page to set up your ad code.


6 Responses to “How To Block Websites on Your Mac Using Terminal”

  1. sarah Says:

    Wow this actually works, thanks!

  2. Michael Says:

    This is awesome! I’m going to use this during finals this semester. One question however… How do you undo it afterwards?

  3. Mason Sklut Says:

    Simple, just go back into Terminal following the same instructions and locate the website you blocked and remove it.

  4. Bob Smith Says:

    Ignore the double period in 127.0..0.1. That was just a typo on my part.

  5. gus Says:

    Cheers dude!

  6. chloe Says:

    I’ve tried a few times and it doesn’t seem to be working for me. Do you need to restart your computer or something?

Leave a Reply