Block Access to Unwanted Websites in Ubuntu 13.10/13.04/Linux Mint

Want to block access to certain websites from your machine running Ubuntu or Linux Mint? It’s easy to do it by editing the host file.

With the hosts file, you can tell Ubuntu to redirect the specific websites to 127.0.0.1. So that the web browser returns below error:

To do so, edit the /etc/hosts with your favorite editor. Press Ctrl+Alt+T on your keyboard to open terminal. When it opens, run below command to edit the hosts via gedit:

sudo gedit /etc/hosts

Add below lines to the end of the file. Exclude the “http://” and change the domain names.

# block access to certain sites
127.0.0.1 www.websites1.com
127.0.0.1 www.websites2.com
127.0.0.1 websites3.com
127.0.0.1 morewebsites.com

Save the file and re-launch your web browser. Done.