Sometimes you might face a situation where you would want to prevent and block access to a certain websites for one reason or another. In Linux blocking an access to an unwanted website(s) can be quite easily achieved with the following simple procedure.
1. Open terminal client (gnome-terminal, lxterminal, guake, or something else)
2. write the following commands to become a root user so you can edit /etc/hosts file
su root
nano /etc/hosts
If you use sudo you can do:
sudo nano /etc/hosts
NOTE: You can replace nano text editor with your own preferred text editor like gedit or kate if you do not wish to use nano like I do.
3. Add the following to the end of /etc/hosts file
0.0.0.0 www.sitename.com
0.0.0.0 value tells Linux to ignore access to a given site mentioned in /etc/hosts file. You can replace www.sitename.com with any web page you may want to block that actually exists online. If you choose to block multiple webpages just add multiple 0.0.0.0 www.sitename.com entries to your /etc/host file.
Once you are done just reboot your Linux box and changes will take effect and unwanted websites are blocked.