Skip to content

Instantly share code, notes, and snippets.

@shikhirsingh
Created August 2, 2020 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shikhirsingh/2f5ba4e877b2b40353a6812156f10305 to your computer and use it in GitHub Desktop.
Save shikhirsingh/2f5ba4e877b2b40353a6812156f10305 to your computer and use it in GitHub Desktop.
How To Block Websites on Your Mac Using Terminal
1. Open up Terminal
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 hit ‘tab’, then enter facebook.com”.
7. On a new line, type in "127.0.0.1" hit ‘tab’, then enter 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment