Tricks & How To's

Block All Domains That Serve Ads, Tracking Scripts and Malware: hBlock

Improve your security and privacy by blocking ads, tracking and malware domains. This POSIX-compliant shell script, designed for Unix-like systems, gets a list of domains that serve ads, tracking scripts and malware from multiple reputable sources and creates a hosts file that prevents your system from connecting to them.


curl -o /tmp/hblock '' \
  && echo 'd402d9b941300c255271a609a063174dc52233fe80049df29b535c1d339bc7dd  /tmp/hblock' | shasum -c \
  && sudo mv /tmp/hblock /usr/local/bin/hblock \
  && sudo chown root:root /usr/local/bin/hblock \
  && sudo chmod 755 /usr/local/bin/hblock



You can also change the default behavior using these options:

Usage: hblock [options...]
 -O, --output FILE            Hosts file location (default: /etc/hosts)
 -R, --redirection IP         Destination IP for all entries in the blocklist
 -H, --header HEADER          Content to be included at the beginning of the
                              hosts file. You can use the output of any other
                              command (e.g. "$(cat header.txt)")
 -S, --sources URLS           Sources to be used to generate the blocklist
                              (whitespace separated URLs)
 -W, --whitelist ENTRIES      Entries to be removed from the blocklist
                              (whitespace separated POSIX BREs)
 -B, --blacklist ENTRIES      Entries to be added to the blocklist
                              (whitespace separated domain names)
 -b, --backup [DIRECTORY]     Make a time-stamped backup in DIRECTORY
                              (default: output file directory)
 -l, --lenient                Match any IP address from sources, although it
                              will be replaced by the destination IP
                              (default:, or none)
 -i, --ignore-download-error  Do not abort if a download error occurs
 -v, --version                Show version number and quit
 -h, --help                   Show this help and quit




Name Primary Mirror URL URL
AdBlock NoCoin List URL URL
AdGuard – Simplified URL URL – Ad URL URL – Malvertising URL URL – Malware URL URL – Tracking URL URL
ETH Phishing Detect URL URL
FadeMind – add.2o7Net URL URL
FadeMind – add.Dead URL URL
FadeMind – add.Risk URL URL
FadeMind – add.Spam URL URL
KADhosts URL URL URL URL – Immortal domains URL URL – Just domains URL URL – Spammers URL URL
mitchellkrogza – Badd-Boyz-Hosts URL URL URL URL URL URL URL URL URL URL
ZeroDot1 – CoinBlockerLists URL URL URL URL

Block All Domains That Serve Ads, Tracking Scripts and Malware

About the author


Add Comment

Click here to post a comment