Use Terminal to Block Websites on Mac

Mac OS X has Hosts file just like Windows. We can edit Hosts via Terminal on a Mac to block specific websites that are not allowed to visit.

  • To edit the hosts file and add a new blocking entry, open up your Terminal and type the following command line (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: If you are using Mac OS 10.4.X, please type the following and press Enter: lookupd –flushcache For Mac OS 10.5.X and later, it can be done by entering the following and press Enter: sudo dscacheutil –flushcache

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 Aobo Web Filter for Mac. It makes the blocking work more convenient and powerful.

Download Aobo Internet Filter for Mac Free Trial Instantly!
Share

Recent Posts

Employee Monitoring Software for macOS Sierra 10.12 Released

EaseMon is the best employee monitoring system for Mac OS X and it was updated…

7 years ago

Amac Keylogger for macOS Sierra 10.12 is available to download

We are delighted to deliver a piece of good news to our users that now…

8 years ago

Aobo Keylogger for macOS Sierra 10.12 is Available to Update

After hard work of day and night, we’d like to share a piece of exciting…

8 years ago

Spy on Keystrokes Inputted on Mac with Spy Technology (Spytech) Keylogger for Mac

Those who want to keep an eye on their children's activities can use Spy Technology…

8 years ago

How is mobile stealth (mobistealth) spy software for Mac useful?

The mobile stealth (mobistealth) spy software for Mac is widely used by many people to…

8 years ago