If you are using Ubuntu and need to block site like Torrent, or Social Networks like Facebook, Twitter, you can do it easy.
Blocking and Unblocking websites in Ubuntu is easy. You can Block them so your kids will not use them, or you can block websites as Root and then the sites will remain blocked for all users.
Blocking and Unblocking Websites through Web Browser
Almost any Linux fresh installed comes with Mozilla Firefox Browser installed as default. Firefox doesn’t have a built-in website blocking feature, but you can get an extension.
You will have to open your Mozilla Firefox Browser then go to Add-ons -> Get Add-ons -> and search for “BlockSite” then click Install.
Or you can go directly to this link to install BlockSite
Then you find BlockSite and you can Add into the list of site you want to block. Also you can set a password so no one will be able to remove blocked websites.
Block and Unblock Websites through the Hots File
Another option for blocking and unblocking websites is by adding them to Hosts file. Also if you want that other users will no be able to edit the hosts file, you can edit it as Root and set it as Read Only.
To edit the hosts file manually you will have to open the terminal and type the following command:
sudo nano /etc/hosts
Then at the last line type each website’s domain name you want to block, including the IP address 127.0.0.1, see example bellow:
127.0.0.1 www.facebook.com 127.0.0.1 thepiratebay.se
After adding the websites, make sure you save the file and then restart your web browser or better restart your system and check if it works.
Note, that hosts file was used for mapping IP addresses to domain names in the past, now it is used for “defining” strict routes. So we are giving the following website an incorrect IP route 127.0.0.1 which is always mapped on your own machine.
Note that you can unblock websites you blocked, the same way you blocked them. Just removing them from lists.
Was this article helpful? Tell us in the comments what methods you use to block websites using Linux.