Here's how you can use the hosts file to block access to web sites in Linux.
1. Open a terminal window.
2. Type in the following command to back up your hosts file, then hit Enter:
sudo cp /etc/hosts /etc/hosts.bak
3. Type in the following command to block Facebook, for example:
sudo sh -c 'echo "0.0.0.0 http://facebook.com" >> /etc/hosts'
4. If you prefer to use a different method, use this command:
sudo sh -c 'echo "127.0.0.1 http://facebook.com" >> /etc/hosts'
To block a different site, just replace facebook.com in the command.
Read more: Linux G