How to manually block advertisements with /etc/hosts
How to manually block advertisements with /etc/hosts
How to manually block advertisements with /etc/hosts
Start a fresh Seamonkey (no cookies, empty cache).
Open only one web site.
Open in another tab : about:cache
You will see many entries : notice which entries are for advertisements.
They are easy to reckognize, it's usually something like ad*** advert*** ads*** track***...
Open /etc/hosts as text with geany.
Add the advertisements to be blocked.
For instance, add the lines :
0.0.0.0 ade.googlesyndication.com
0.0.0.0 adservice.google.com
0.0.0.0 www.googleadservices.com
0.0.0.0 www.google-analytics.com
0.0.0.0 www.googletagmanager.com
0.0.0.0 www.googletagservices.com
0.0.0.0 www.googletagmanager.com
0.0.0.0 pagead2.googlesyndication.com
0.0.0.0 ssl.google-analytics.com
0.0.0.0 platform.twitter.com
0.0.0.0 widgets.outbrain.com
0.0.0.0 c.amazon-adsystem.com
etc. etc.
There can be dozens of them.
Save.
Leave Seamonkey and reopen the example website. You will see it loading cleaner and faster.
Do this for each of your favorite websites.
Start a fresh Seamonkey (no cookies, empty cache).
Open only one web site.
Open in another tab : about:cache
You will see many entries : notice which entries are for advertisements.
They are easy to reckognize, it's usually something like ad*** advert*** ads*** track***...
Open /etc/hosts as text with geany.
Add the advertisements to be blocked.
For instance, add the lines :
0.0.0.0 ade.googlesyndication.com
0.0.0.0 adservice.google.com
0.0.0.0 www.googleadservices.com
0.0.0.0 www.google-analytics.com
0.0.0.0 www.googletagmanager.com
0.0.0.0 www.googletagservices.com
0.0.0.0 www.googletagmanager.com
0.0.0.0 pagead2.googlesyndication.com
0.0.0.0 ssl.google-analytics.com
0.0.0.0 platform.twitter.com
0.0.0.0 widgets.outbrain.com
0.0.0.0 c.amazon-adsystem.com
etc. etc.
There can be dozens of them.
Save.
Leave Seamonkey and reopen the example website. You will see it loading cleaner and faster.
Do this for each of your favorite websites.
Last edited by linuxcbon on Tue 19 Mar 2019, 21:45, edited 3 times in total.
Nice tips linuxcbon.
It can however be applied to pretty much any browser and O.S.
I generally detest adverts when browsing for two reasons:
1) Wastes my time
2) Wastes my bandwidth/cap.
I do make one or two exceptions and one being the advert shown on this forum.
It takes money to maintain and host a site like this one and since it helps me,
I don't block ads here.
Once you know which ads you want to block, simply edit your hosts file
and presto, no more annoying adverts.
The location of your hosts file will differ depending on your O.S.
A few examples:
For NT, Win2K & XP, it's located in "C:\windows\system32\drivers\etc\hosts"
or "C:\winnt\system32\drivers\etc\hosts"
For Windows 7 & Vista, it's in "C:\windows\system32\drivers\etc\hosts"
or "%systemroot%\system32\drivers\etc\hosts"
Keep in mind that if you have anti-virus software running (M$ Security Essentials included),
you will have to either temporarily disable the anti-virus software or allow the change.
For Linux, simply search for /etc/hosts
Remember that for non-root distros such as Ubuntu, you will first have to run as root.
For Mac, I have no idea.
When editing the hosts file, always use the top level domain name
such as:
0.0.0.0 www.google-analytics.com
and not:
0.0.0.0 http://www.google-analytics.com/ga.js
Depending on your setup, you may also have to replace 0.0.0.0 with 127.0.0.1
Of course this method is not limited to blocking just adverts and can be
used to protect other members of your household from "nasty" sites.
There are plenty of lists on the net for all sorts of unsavoury websites
which you can add to your hosts file.
Happy surfing.
It can however be applied to pretty much any browser and O.S.
I generally detest adverts when browsing for two reasons:
1) Wastes my time
2) Wastes my bandwidth/cap.
I do make one or two exceptions and one being the advert shown on this forum.
It takes money to maintain and host a site like this one and since it helps me,
I don't block ads here.
Once you know which ads you want to block, simply edit your hosts file
and presto, no more annoying adverts.
The location of your hosts file will differ depending on your O.S.
A few examples:
For NT, Win2K & XP, it's located in "C:\windows\system32\drivers\etc\hosts"
or "C:\winnt\system32\drivers\etc\hosts"
For Windows 7 & Vista, it's in "C:\windows\system32\drivers\etc\hosts"
or "%systemroot%\system32\drivers\etc\hosts"
Keep in mind that if you have anti-virus software running (M$ Security Essentials included),
you will have to either temporarily disable the anti-virus software or allow the change.
For Linux, simply search for /etc/hosts
Remember that for non-root distros such as Ubuntu, you will first have to run as root.
For Mac, I have no idea.
When editing the hosts file, always use the top level domain name
such as:
0.0.0.0 www.google-analytics.com
and not:
0.0.0.0 http://www.google-analytics.com/ga.js
Depending on your setup, you may also have to replace 0.0.0.0 with 127.0.0.1
Of course this method is not limited to blocking just adverts and can be
used to protect other members of your household from "nasty" sites.
There are plenty of lists on the net for all sorts of unsavoury websites
which you can add to your hosts file.
Happy surfing.
If you use Yahoo and don't want all the pics and flash ads all over the place,
add the following entries to your hosts file:
0.0.0.0 l1.yimg.com
0.0.0.0 l.yimg.com
0.0.0.0 row.bc.yahoo.com
You may have to add a few more that Yahoo uses for it's localisation
depending on which country you're in.
It now loads in a quarter of the time, admittedly it does not look as pretty but
saves a lot of bandwidth by not loading all that "eye-candy".
To "tame" Google:
0.0.0.0 googleads.g.doubleclick.net
0.0.0.0 pagead2.googlesyndication.com
This is not an exhaustive list and I'm sure they use plenty of others.
Great for mobile devices.
Apparently the hosts file is located at /system/etc/hosts for the Android OS.
Anyone know where it is for other devices such as the iPad/phone, blackberries, etc etc?
EDIT:
Whilst searching around for the location of the hosts file for the iPad,
I went to stackoverflow and found something, not good news:
http://stackoverflow.com/questions/4783 ... -host-file
Also got pretty fed up with the ads there so here are some more entries:
0.0.0.0 engine.adzerk.net
0.0.0.0 static.adzerk.net
EDIT 2:
If you want to watch a YouTube video without the big advert on the top
right hand side, add:
0.0.0.0 googleads.g.doubleclick.net
If you don't want to see the icons of the other clips (on the RHS), add:
0.0.0.0 i1.ytimg.com
0.0.0.0 i2.ytimg.com
0.0.0.0 i3.ytimg.com
0.0.0.0 i4.ytimg.com
See the attached screen shot.
Now YouTube loads much faster.
add the following entries to your hosts file:
0.0.0.0 l1.yimg.com
0.0.0.0 l.yimg.com
0.0.0.0 row.bc.yahoo.com
You may have to add a few more that Yahoo uses for it's localisation
depending on which country you're in.
It now loads in a quarter of the time, admittedly it does not look as pretty but
saves a lot of bandwidth by not loading all that "eye-candy".
To "tame" Google:
0.0.0.0 googleads.g.doubleclick.net
0.0.0.0 pagead2.googlesyndication.com
This is not an exhaustive list and I'm sure they use plenty of others.
Great for mobile devices.
Apparently the hosts file is located at /system/etc/hosts for the Android OS.
Anyone know where it is for other devices such as the iPad/phone, blackberries, etc etc?
EDIT:
Whilst searching around for the location of the hosts file for the iPad,
I went to stackoverflow and found something, not good news:
http://stackoverflow.com/questions/4783 ... -host-file
Also got pretty fed up with the ads there so here are some more entries:
0.0.0.0 engine.adzerk.net
0.0.0.0 static.adzerk.net
EDIT 2:
If you want to watch a YouTube video without the big advert on the top
right hand side, add:
0.0.0.0 googleads.g.doubleclick.net
If you don't want to see the icons of the other clips (on the RHS), add:
0.0.0.0 i1.ytimg.com
0.0.0.0 i2.ytimg.com
0.0.0.0 i3.ytimg.com
0.0.0.0 i4.ytimg.com
See the attached screen shot.
Now YouTube loads much faster.
- Attachments
-
- YouTube_NoAds.jpg
- (102.68 KiB) Downloaded 1608 times
List of hosts
I suggest to use the .txt file from:
http://msmvps.com/blogs/hostsnews/default.aspx
to block by /etc/hosts most common adverts.
http://msmvps.com/blogs/hostsnews/default.aspx
to block by /etc/hosts most common adverts.
Re: List of hosts
This has nothing to do with this howto.watchdog wrote:I suggest to use the .txt file from:
http://msmvps.com/blogs/hostsnews/default.aspx
to block by /etc/hosts most common adverts.
Here is explained how to write your file "manually", so you have full control. I recommend you do it yourself manually.
- fabrice_035
- Posts: 765
- Joined: Mon 28 Apr 2014, 17:54
- Location: Bretagne / France
Once again this is out of topic, and you need a special hardware like a raspberry-pi , install the software and set the settings. All that is more complicated than a simple file.fabrice_035 wrote:Hey,
If you have a Raspberry-Pi, i advise you to use Pi Hole!
[im g]http://i66.tinypic.com/2d11lck.jpg[/img]
for all peripherals (smartphone, computer, ... ) Raspberry it becomes the dns server, he does the work, block or allow.
Alternative edit /etc/hosts in your computer
Regard.
But you can write a howto for your method if you want to.
I have never used Windows, but I get my /etc/hosts/ setup from a Windows site: http://winhelp2002.mvps.org/hosts.htm
Just add the file to your /etc/hosts, but ensure that the top lines are the ones that are there default.
etc. down to line 14326 (I am sure there are more now...)
It works.
Just add the file to your /etc/hosts, but ensure that the top lines are the ones that are there default.
Code: Select all
127.0.0.1 localhost puppypc
192.168.1.1 pc2
192.168.1.2 pc3
192.168.1.3 pc4
# This MVPS HOSTS file is a free download from: #
# http://winhelp2002.mvps.org/hosts.htm #
# [Misc A - Z]
0.0.0.0 fr.a2dfp.net
Code: Select all
0.0.0.0 www.winaproduct.com
# [end of entries generated by MVPS HOSTS]
True freedom is a live Puppy on a multisession CD/DVD.
Wwwwhhhhhaaaaaaattttt?tallboy wrote:I have never used Windows (...)
First reaction:
You dropped to Earth from Aldebaran yesterday, yes?
Second reaction:
tallboy must be a saint. He took a vow of no-WhineDose when he
entered his monastic order.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
As I wrote, this tutorial is not about downloading some external hosts file. It is about writing it yourself, manually, by looking at "about:cache".tallboy wrote:I have never used Windows, but I get my /etc/hosts/ setup from a Windows site: http://winhelp2002.mvps.org/hosts.htm
It's safer as you know what is inside and the file is shorter so it's faster for your browser to run.
Re: List of hosts
Hi linuxcbon,
Mostly I agree with you. This is an important topic and it is your thread. The posts to it should primarily be about how to create you own hosts file with, perhaps, a secondary concern with identifying --as Dave_G did-- urls a user is likely to want to block, and why.
Each of us has his or her own priorities. That each of us proceed by 'trial and error' is not really efficient. Once you know how to create your own, however, you will be better able to interpret/understand those lists prepared by others which can be found on the Web. Such lists are only just that, lists. Although they can be used --and some may be satisfied with doing that-- they can be modified: urls added or deleted. In other words, "How to Create You Own" properly includes "Creating your own block list by modifying a list created by others". Recommendations regarding which list to start with would be relevant and particularly helpful for those new to this area.
Having one thread to which members of the Puppy community can look for advice regarding host files is, IMHO, much preferable to adding to the maze that this Forum has a tendency to become.
Rather than excluding mention of prepared lists, may I suggest that those who are familiar with them and would recommend one explain why it is recommended. I hope, however, that others may not take this suggestion as an invitation to engage in flame wars regarding the merits of one list over another.
With that method of individual customization in mind, Tallboy's post, http://murga-linux.com/puppy/viewtopic. ... 68#1008768 explaining the proper way to add to an existing list is particularly helpful.
Emphasis mine.linuxcbon wrote:This has nothing to do with this howto.watchdog wrote:I suggest to use the .txt file from:
http://msmvps.com/blogs/hostsnews/default.aspx
to block by /etc/hosts most common adverts.
Here is explained how to write your file "manually", so you have full control. I recommend you do it yourself manually.
Mostly I agree with you. This is an important topic and it is your thread. The posts to it should primarily be about how to create you own hosts file with, perhaps, a secondary concern with identifying --as Dave_G did-- urls a user is likely to want to block, and why.
Each of us has his or her own priorities. That each of us proceed by 'trial and error' is not really efficient. Once you know how to create your own, however, you will be better able to interpret/understand those lists prepared by others which can be found on the Web. Such lists are only just that, lists. Although they can be used --and some may be satisfied with doing that-- they can be modified: urls added or deleted. In other words, "How to Create You Own" properly includes "Creating your own block list by modifying a list created by others". Recommendations regarding which list to start with would be relevant and particularly helpful for those new to this area.
Having one thread to which members of the Puppy community can look for advice regarding host files is, IMHO, much preferable to adding to the maze that this Forum has a tendency to become.
Rather than excluding mention of prepared lists, may I suggest that those who are familiar with them and would recommend one explain why it is recommended. I hope, however, that others may not take this suggestion as an invitation to engage in flame wars regarding the merits of one list over another.
With that method of individual customization in mind, Tallboy's post, http://murga-linux.com/puppy/viewtopic. ... 68#1008768 explaining the proper way to add to an existing list is particularly helpful.
Instead of constantly messing with it, I just download mvphosts: http://winhelp2002.mvps.org/hosts.zip
They update that file every week. They are "doing the lord's work", so to speak.
I hope this helps ..
They update that file every week. They are "doing the lord's work", so to speak.
I hope this helps ..
I came here with blessings from the planet Mac, I will not harm your RAM!musher0 wrote:tallboy wrote:
I have never used Windows (...)
Wwwwhhhhhaaaaaaattttt? Wink
First reaction:
You dropped to Earth from Aldebaran yesterday, yes? Twisted Evil
Second reaction:
tallboy must be a saint. Laughing He took a vow of no-WhineDose when he
entered his monastic order. Laughing
Wink
I have to admit that a few programs at the Uni were available for Windoze only, but they always included a very good manual!
True freedom is a live Puppy on a multisession CD/DVD.
I believe you can do this in one shot withlinuxcbon wrote:Two more things :
1/ how to sort the hosts file alphabetically :
# sort +1 -2 /etc/hosts > toto.txt
toto.txt is the new sorted file.
2/ then you can remove duplicates from toto.txt and update hosts :
uniq toto.txt > /etc/hosts
Code: Select all
# sort +1 -2 -u /etc/hosts > toto.txt
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
linuxcbon and musher0, the guys at winhelp2002 must have read your posts about sorting and removing duplicates, because their latest HOSTS is only 14176 lines long!
Correction: After running the script, it shrank to 13981 active lines, so they haven't read your posts after all!
Correction: After running the script, it shrank to 13981 active lines, so they haven't read your posts after all!
True freedom is a live Puppy on a multisession CD/DVD.