Blocking websites on Linux: the options, and what each can't do
Description and use
The author reviewed Linux website blocking options, identified their weaknesses, and built glocker, which removes sudo during scheduled hours and requires a typing challenge to uninstall, providing stronger enforcement.
Problem
The author needed a reliable way to block websites and apps on Linux that could not be easily undone by the user.
Outcome
glocker provides a more robust blocking solution by disabling sudo during scheduled hours, making uninstallation difficult, and offering accountability notifications, addressing gaps in other methods.
Workflow
- 1. Identify the sites/apps to block.
- 2. Choose a blocking method: /etc/hosts, DNS filter, browser extension, blocker app, or glocker.
- 3. Configure the chosen tool (e.g., add hosts entries, set DNS filter, install extension, or install glocker).
- 4. For glocker, set schedule, disable sudo during blocked hours, and configure optional dashboard for accountability.
- 5. Verify blocking works and that sudo is disabled during scheduled hours.
- 6. Monitor for gaps (e.g., DNS-over-HTTPS, other browsers, second devices).
Evidence
I made the file immutable with chattr +i /etc/hosts. After that, even root can't edit it without first running chattr -i.
A filter only works while traffic goes through it, though. On a laptop, changing the DNS server, or connecting from somewhere else, gets around it.
It only covers the browser it's installed in. An incognito window, another browser, another profile, or two clicks in the add-ons menu, and the blocks are gone.
The gap they all share is root. If you can run sudo, you can stop the service, edit the files or uninstall the app, so any of them can be undone in a minute when you really want to.
It takes away my sudo during the hours I choose, so I can't stop the service, edit the hosts file or uninstall it.
Uninstalling is slow on purpose. I have to type a sentence that's revealed one character at a time, and start again if I slip.
- Record date: 2026-11-01T15:13:44.225Z