by Paul Arnote (parnote)
If you browse the internet (what computer user these days doesn't?), it's a necessity to be vigilant in making your browsing experience secure. Many users don't want their browsing habits to be reported back to online advertisers and other "data mining" sites, like Google, Twitter, Microsoft and Facebook. Most of the time, users are content in just blocking ads from appearing. But given that Facebook has been discovered to be collecting data on all users -- not just Facebook members -- blocking certain sites is becoming even more and more important to protect our online browsing experience. Let's first take a look at blocking ads.
Everyone and anyone who has browsed the internet has been bombarded with a steady stream of advertisements. Why advertisers continue to subscribe to this intrusive marketing ploy is a mystery. A lot of users feel the same as I do, shunning any advertiser who intrusively thrust their products upon me when I'm trying to be productive doing other tasks.
In my honest opinion, it's a waste of advertising dollars. Sure, it generates revenue for websites (such as the PCLinuxOS website), but it also "turns off" just as many computer users. It's unfathomable that marketing managers would risk alienating and driving away such a large number of potential customers. Browsing the web without some kind of ad blocking software tends to leave me feeling "dirty" and abused.
So, how can a computer user protect themselves from the constant barrage of unwanted and unnecessary advertising? Even more, how can a computer user help protect their data from those companies who ruthlessly mine and collect user data, only to have that information resold to who knows who? Thankfully, there are solutions, and one of them is right under your nose.
One of the more common ways to prevent being mauled and molested by unwanted online advertising is to run a browser plugin that blocks the display of ads. Probably one of the most popular ad blocking plugins is Adblock Plus, a.k.a. ABP.
Adblock Plus is available for Firefox, Chrome/Chromium, Opera, Android and Internet Explorer. We've covered Adblock Plus previously in The PCLinuxOS Magazine, as part of a Firefox add-ons article. Setting it up is relatively painless and easy.
Adblock Plus is an open source plugin/add-on, and is the most popular browser extension around. The latter illustrates perfectly how interested internet users are in blocking the annoying and intrusive ads from disrupting their browsing experience.
One advantage of using Adblock Plus is that you can turn it off on websites that you specify. This allows the viewing of ads on a site-by-site basis. The upside of this is that it allows you to help generate ad revenue for sites that you frequent, like the PCLinuxOS website, that rely on that ad revenue to help pay for server space and site administration.
Edit Your /etc/hosts File
The other way to eliminate ads from your browsing experience is to edit your /etc/hosts file to prevent the ads from being displayed. It does this by blocking the server on which the ads reside. Linux, Unix, Windows and OS-X all have a "hosts" file, so this method will work for all of those platforms. Only the details for each individual operating system will differ. We'll focus on how to do this under Linux (of course), and particularly PCLinuxOS.
You could add the server sites, one by one, to the end of your /etc/hosts file. But, that would take a long time, and you're bound to miss a lot of the ad servers. Fortunately, there's someone (Peter Lowe) who has taken the time to not only amass all of these ad servers into one list, but also works tirelessly to maintain that list. You can view or download the entire list from here, on his website. At the time that I wrote this article, there are 2,550 ad servers in the list.
Since the hosts file exists in the /etc directory, you will need root access to edit the file. In a terminal session, enter the command below that corresponds to your particular desktop environment.
KDE: kdesu kwrite /etc/hosts &
Mate: gksu pluma /etc/hosts &
Xfce: gksu mousepad /etc/hosts &
LXDE: gksu leafpad /etc/hosts &
e17: gksu leafpad /etc/hosts &
The ad server list displayed in Mousepad on Xfce.
After entering the appropriate command in your terminal, hit enter. Supply the root password, and your hosts file should be open and available for editing. IMPORTANT NOTE: Before you do anything else, select File > Save As... and save your /etc/hosts file with the file extension of .bak to make a backup copy ... just in case something gets messed up, you still have your original hosts file stored, intact. Copy the list above, then move your cursor to the end of the hosts file, and paste the list.
If there are advertisers you want to allow, place a "# " in front of the line that lists the ad server you want to allow. Let's say, for example, you want to allow ads on the PCLinuxOS site (so that you can help support PCLinuxOS). Look through the list, and if it appears, change the line that reads "127.0.0.1 contextual.media.net" to "# 127.0.0.1 contextual.media.net." (At the time that I wrote this article, contextual.media.net was not in the list). In fact, any line that starts with "# " is treated as a comment and is ignored.
Once you've added "the list" to your hosts file, select File > Save As... and save it as your hosts file (no file extension). You should get a confirmation dialog asking if you want to overwrite your hosts file. Select to overwrite the original hosts file. Restart your browser.
The benefits of using this method is that it is a universal setting that applies to every user on your computer. The main disadvantage is that you cannot selectively allow ads on some sites but not others, if they originate from the same ad server. Another disadvantage (and an advantage in other aspects) is that you must have root level permissions to add or delete items. Plus, you will also have to make sure that you keep your "block" list updated periodically, as ad servers are added, subtracted and changed. Updating once every three or four months should be sufficient to block most ads.
"Other" Security Concerns
Earlier, we talked about how Facebook (and other sites) amasses and collects data on all computer users -- not just Facebook members. Recently, the Sandbox section of the PCLinuxOS forum was closed to viewing by guests to the forum. Now, only forum members can see the Sandbox section. Texstar did this after he discovered a Facebook bot crawling over the Sandbox posts, collecting all the data it could. So, whether you have a Facebook account or not, chances are high that Zuckerberg and Co. have collected a LOT of data on you, including your browsing habits, purchasing habits and anything else it thinks it can sell.
Let's explore another scenario. Let's say you have set up a computer for your child in his or her room to help complete school homework. But, being the responsible parent that you are, you don't want your child spending their time on Facebook (let's pick on Facebook here -- they are a worthy site to pick on) instead of doing homework.
In either case, you can add Facebook to your "blocked sites" list in your hosts file. Simply add (as root, again) "127.0.0.1 facebook.com" to the end of your hosts file. Now, restart your browser. Try entering "http://www.facebook.com" into your browser's address bar. Surprise! That computer will no longer be able to connect to Facebook. As an added benefit, Facebook will also not be able to track any of your movements across the web. The latter is an important consideration, especially if you don't have a Facebook account.
You can do this for any site that you a) don't want users visiting, or b) don't want tracking your browsing habits. It's important to use some discretion in what sites you add to the list. For example, Google has become so pervasive that no Google services will be accessible (Google Earth, Picasa, Google +, Gmail, etc.), and sites that you might not think of as having a link to Google may become inaccessible, especially if they use Google's search services to provide a search environment.
Users of the web have a few different choices in how to prevent the display of ads, and to help protect their browsing experience. With the current trend of wholesale data collection by nefarious web sites, protecting your data and browsing habits is more important than ever.