Linux How To's | Bash Scripting | Python

Monday, 30 September 2013

Most of us have been using several social networking websites in order to stay in touch with our friends and family members online. Most of the parents are worried about their kids that they may get addicted to these social networking sites (and porn sites also). As a result of this, their children may be fetch poor grades in exam. Not only this, but the use of these social networking websites may reduce productivity in offices, companies and other working environments. No doubt that there are variety of filters and firewalls being used to ban the access to these websites, but you need to spend considerable amount of money to use them.
Whether you wish to restrict access to social media websites for yourself or prevent others from doing so, you may go through this simple procedure to ban access to any website in any Ubuntu/Linux Mint system. The beauty of this trick is that, it will ban both the HTTP and the HTTPS protocols and it can be implemented in any system running Ubuntu or Linux Mint :

Lets Do It !

Step 1: Open the /etc/hosts file with your favorite text editor:

sudo gedit /etc/hosts

Step 2: Append following lines at the end of this file:

# Blocking <Website_Name>
127.0.0.1 www.website_name.com

Just replace the text "www.website_name.com" with the name of the website you wish to block. This line will map www.website_name.com to 127.0.0.1.

As an example, I will block access to www.facebook.com.

Output:

After editing the file, save it and restart the system using following command:

sudo reboot

Now, when you try to open the website, you will get the following result: