Skip to content

Instantly share code, notes, and snippets.

@hrosenbauer
Created May 14, 2014 13:08
Show Gist options
  • Select an option

  • Save hrosenbauer/f4cecde89185c00206c6 to your computer and use it in GitHub Desktop.

Select an option

Save hrosenbauer/f4cecde89185c00206c6 to your computer and use it in GitHub Desktop.
adblock via hosts file

hosts files layout:

/etc/hosts		('compiled' version)
/etc/hosts.d/
/etc/hosts.d/adblock	(adblocking hosts file)
/etc/hosts.d/base	(original system hosts file)
/etc/hosts.d/dev	(work-related file for development)

.bashrc:

function update-hosts() {
	cat /etc/hosts.d/* > /etc/hosts;
}

function update-adblock() {
	curl http://someonewhocares.org/hosts/zero/hosts -o /etc/hosts.d/adblock 2> /dev/null
	update-hosts
}

howto:

sudo update-adblock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment