hBlock is a POSIX-compliant shell script that gets a list of domains that serve ads, tracking scripts and malware from multiple sources and creates a hosts file, among other formats, that prevents your system from connecting to them.
On this website you can download the latest build of the default blocklist and you can generate your own by following the instructions on the project page (github.com/hectorm/hblock).