0

Has anyone used this method: http://www.putorius.net/2012/01/block-unwanted-advertisements-on.html

I tried per instructions. Maybe I'm too new to Linux, it's not working for me.

While looking for etc/hosts I came across hosts.allow and hosts.deny. Do I simply add doamains to the hosts.deny list ?

7
  • Which browser are you using? There are much simpler ways to block ads.
    – Wilf
    Jul 24, 2014 at 17:40
  • Firefox. Adblock extensions slow the browser down too much, esp with no preloader for linux.
    – user308751
    Jul 24, 2014 at 17:59
  • Noscript is a pretty lightweight way to block ads - see here
    – Wilf
    Jul 24, 2014 at 19:36
  • I've used noscript it helped me with a rendering issue I was having in windows that I'm not encountering in linux. It's a bit time consuming I find because of each site needing to be tuned.
    – user308751
    Jul 24, 2014 at 19:55
  • hosts.allow and hosts.deny are not hosts.
    – psusi
    Jul 25, 2014 at 3:21

1 Answer 1

4

The main problem there is that it assumes the user is root. I modified the script to add in sudo, so that any user allowed to use sudo can use the script.

#!/bin/bash
cp /etc/hosts ~/.etchosts
cd /tmp
wget http://winhelp2002.mvps.org/hosts.txt
sudo rm /etc/hosts
sudo mv hosts.txt /etc/hosts
cat ~/.etchosts | sudo tee -a /etc/hosts

That being said, I recommend you use an extension in whichever browser(s) you use to block ads there instead of messing with /etc/hosts. I find the extensions do a better job of blocking ads while allowing content.

9
  • Thank you. I use Firefox and find that adblock extensions slow the browser down too much, esp with no ppreloader for start up. If I run this script is a text editor supposed to open and do I modify anything there, for example like when I modified memory swap settings earlier ? This is all new to me. Thanks
    – user308751
    Jul 24, 2014 at 18:15
  • @user308751: No, nothing is supposed to open. You can either save the script to a file, mark it as executable (chmod +x fileName), and then run it (./fileName), or just copy the script line by line (starting with the second line). Jul 24, 2014 at 18:18
  • ok thank you. Curious, when I try to manually modify any host file then save changes, I get the access denied message. How do I gain access ?
    – user308751
    Jul 24, 2014 at 19:12
  • If you aren't using sudo, and you aren't root, then you get the access denied message. You can use sudo vim /etc/hosts or sudoedit /etc/hosts (which uses your default editor) to edit /etc/hosts. Jul 24, 2014 at 19:13
  • ok got it I was going straight at it, just came over from windows thank you
    – user308751
    Jul 24, 2014 at 19:25

Not the answer you're looking for? Browse other questions tagged .