04 March 2010

Blocking Time Wasting Websites (on Ubuntu Linux)

I recently found myself wasting more and more time going to interesting, somewhat informative, and more or less completely useless websites. I'm talking about Slashdot, Digg, and others. Especially Hacker News, which sometimes has some great links to programming related articles and blog posts. It's just like this XKCD comic here.

The solution came in blocking the habit, but blocking the specific websites that are such time wasters most hours.

How to do this? A quick Google Search gives us the complicated answer.

In short, there's generally two ways of blocking specific websites. Through the hosts file, and through the firewall.

Looking at How To Block Unwanted Website In Ubuntu Linux and this question from Ubuntu Forums reveals how to block through the hosts file. They gave answers that works in the terminal, but if you are on Ubuntu, you can also key in alt-f2 to bring up the Run Application menu, then key in gksudo gedit /etc/hosts. It'll ask for your password, then a text configuration file will open up. Add in, each on its own line,     www.digg.com (whichever site you want, and that's a tab between the 0 and w). I think after you're done, this requires a restart though.

But that requires touching a text configuration file, and I don't like that. If there's a GUI method, I usually prefer that out of laziness. So here's a GUI method.

You can also block sites via the firewall controlled by iptables as described in this Linux Questions. Unfortunately, it still requires going to the terminal and typing in some commands. If you have Firestarter installed, however, you won't have to! (You can install Firestarter via the Ubuntu Software Center, under the Applications menu.)

This is a great GUI controller for the firewall. You can start and stop it, look at some status info. You can also click on the Policy tab, select Outbound traffic policy in the Editing menu under the tab, make Permissive by default selected, then right-click on the white area beneath Deny connections to host. That will bring up a menu to select Add Rule, which brings up a window to add in the hosts you want blocked, eg, reddit.com.

And that's it. A pretty GUI method.

No comments: