How to control site access in Linux: Block unwanted websites

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 value tells Linux to ignore access to a given site mentioned in /etc/hosts file. You can replace with any web page you may want to block that actually exists online. If you choose to block multiple webpages just add multiple 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.