How to block web sites in Linux by using the hosts file

Use the hosts file to block access to sites in Linux

By , ITworld |  Internet, block sites in linux hosts file, block websites linux

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

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness