Most guides to blocking websites on Linux stop at "add a line to /etc/hosts ". That works, but it didn't help me much, because the person I was trying to stop was me. These are the things I tried or looked at over the years, what each was good for, and where each one gave way.
Editing /etc/hosts
This is where I started. A line like this in /etc/hosts sends the site nowhere:
0.0.0.0 twitter.com 0.0.0.0 www.twitter.com
Enter fullscreen mode
Exit fullscreen mode
It works on every distro and costs nothing, and the block holds until you remove it. The trouble is that removing it is easy: open the file, delete the line, and the site is back.
So I made the file immutable with chattr +i /etc/hosts . After that, even root can't edit it without first running chattr -i . It's only one more command, but on an ordinary day that extra step was often enough to make me stop and think.…