How To Block Unwanted Website In Ubuntu Linux

If your Ubuntu computer is used by some one else besides yourself, specially children, then you might want to restrict some websites and make sure they do not open on your system. Here is a quick way to block such sites in Ubuntu. It is extremely simple doesn’t require any third party application, you just need to make a simple entry in the /etc/hosts file.

/etc/hosts is a very important file which handles DNS and internet handling on Linux based systems. In order to block some site from opening, open the /etc/hosts file by typing the following command on the terminal:

gedit /etc/hosts

and add the following line:

127.0.0.1   domain.com

Here replace domain.com with the name of the domain that you wish to block.

Now whenever there is an attempt to open the blocked website, the web browser will display the “Failed To Connect” message.

Firefox Ubuntu

  • Share this article!

    • Digg this!
    • Bookmark on Reddit
    • Bookmark at Delicious
    • Stumble this!
    • Share this post at Facebook
    • Tweet this!
    • Share on Yahoo! Buzz
    • Add AddictiveTips to your Technorati favorites
    • Share on Friendfeed
This entry was posted in Ubuntu Linux and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

13 Comments

  1. deewangan
    Posted January 4, 2010 at 7:45 am | Permalink

    it doesn't work for me, i am using ubuntu 8.10, any idea why?

  2. DavidDailey86
    Posted February 26, 2010 at 6:46 am | Permalink

    in terminal, type: sudo su
    enter your password
    then type: gedit /etc/hosts

    add the line
    127.0.0.1 siteyouwannablock.com

    make sure you exclude the “http://” and make sure you block all sub-domains of the site.

    hope this helped!
    example:

    127.0.0.1 siteyouwannablock.com
    127.0.0.1 http://www.siteyouwannablock.com
    127.0.0.1 ad-server.siteyouwannablock.com

    • muhin
      Posted May 10, 2010 at 8:45 pm | Permalink

      i made it. write likes (must give same coloumn between 127.0.0.1 and http://www.facebook.com on above)

      127.0.0.1 localhost
      127.0.1.1 muhinboss-desktop
      127.0.0.1 http://www.facebook.com

      # The following lines are desirable for IPv6 capable hosts
      ::1 localhost ip6-localhost ip6-loopback
      fe00::0 ip6-localnet
      ff00::0 ip6-mcastprefix
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      ff02::3 ip6-allhosts

  3. Gus
    Posted April 18, 2010 at 12:49 am | Permalink

    How do I unblock it now?

  4. muhin
    Posted May 10, 2010 at 8:28 pm | Permalink

    i can not save hosts file bcz it’s read only (unchangeable)… now how can i save hosts file??

    • muhin
      Posted May 10, 2010 at 8:38 pm | Permalink

      now i found how it can be save.

      • Tduck
        Posted July 7, 2010 at 5:02 am | Permalink

        I got the same trouble. How do you fix it?

  5. Posted May 12, 2010 at 2:24 pm | Permalink

    i undrstood how to block a website in single machine but how 2 block website for all users on same network.

    • Rh354
      Posted June 22, 2010 at 12:41 pm | Permalink

      you can use squid+squidguard for that

  6. Posted June 13, 2010 at 12:21 pm | Permalink

    i want to block all the sites in my computer which is related to porn stars,porn movies please help me

  7. Bodincus
    Posted June 26, 2010 at 7:00 am | Permalink
  8. asgar ali m k
    Posted August 9, 2010 at 1:07 am | Permalink

    how to unblock?

  9. Henkipje
    Posted August 19, 2010 at 12:17 pm | Permalink

    How can I unblock this site now?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


More in Ubuntu Linux,Windows (5 of 5 articles)