Just like Windows you can easily block websites in Linux too. However before Windows Vista everyone can edit HOSTS file but now only Administrator can edit HOSTS file in Windows Vista and Windows 7. Similarly in Ubuntu there exist a HOSTS file which can be used to block websites. Only root user is allowed to edit HOSTS file. So in order to edit HOSTS file from a normal account, you have to use SUDO command.
How To Block Websites Using HOSTS File
Open Terminal by navigating to Applications->Accessories->Terminal
Use the following command to edit HOSTS file
sudo gedit /etc/hosts
Suppose you want to block YouTube and Facebook on Ubuntu. Just add the following two lines in file as shown in the screenshot and click save.
Restart your computer. Now you won't be able to access these websites, no matter whatever web browser you use ;)
Note: You can find number of custom HOSTS file on Internet created to block advertisements and stuff etc.Contact Us for News Tips, Corrections and Feedback