This tutorial will explain how to block any website on Ubuntu by adding rules to /etc/hosts file.
This can be used for parent control, un-block need user password to get root privilege.

Open terminal from the dash home(or press Ctrl+Alt+T), and do following steps:

  • 1. Edit /etc/hosts file with gedit:
    sudo gedit /etc/hosts
  • 2. Add following line to block (change siteyouwanttoblock.com):
    127.0.0.1 siteyouwanttoblock.com

    Just for example, to block google.com, google map add following:

    127.0.0.1 google.com
    127.0.0.1 www.google.com
    127.0.0.1 maps.google.com

  • 3. Now restart your web browser and blocked sites won’t available.

To un-block them, just remove rules you added in /etc/hosts.