A simple system service for Linux to block distracting websites.
This tool helps you stay focused by making it intentionally difficult to access distracting sites.
The goal is to create friction. By making it hard to get distracted, this tool turns an impulsive click into a conscious choice, giving you a chance to stay on task. There is no easy "off" switch.
- Blocks Sites: The service edits your
/etc/hostsfile to block a list of common distracting websites. - Always On: It starts when your computer boots and runs constantly.
- Self-Healing: If you manually edit the
/etc/hostsfile to unblock a site, the service will automatically block it again. - Clean Shutdown: When you shut down or reboot your computer, the service automatically cleans up its changes, leaving your system untouched.
You can install dsfree either from a pre-compiled binary for convenience or by building it from the source code.
Prerequisites for all methods:
- A Linux system with
systemd. sudoaccess.
This is the easiest way to get started.
-
Download the latest binary from the Releases Page.
-
Make the binary executable and move it to a system path. In your terminal, navigate to where you downloaded the file and run:
chmod +x dsfree sudo mv dsfree /usr/local/bin/
-
Continue to "Set Up the Service" below.
Prerequisite: Go compiler (version 1.18+).
-
Clone this repository and build the binary:
git clone https://github.com/serisow/dsfree.git cd dsfree go build -o dsfree -
Move the compiled binary to a system path:
sudo mv dsfree /usr/local/bin/
-
Continue to "Set Up the Service" below.
This final step is required for both installation methods.
-
Create the
systemdservice file:sudo nano /etc/systemd/system/dsfree.service
-
Paste this content into the file:
[Unit] Description=Blocks distracting websites by editing /etc/hosts After=network.target [Service] User=root ExecStart=/usr/local/bin/dsfree KillMode=none Restart=on-failure [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable dsfree sudo systemctl start dsfree
The service is now active and will start on every boot.
- To check the service status:
systemctl status dsfree
- To stop the service:
The service is designed to ignore standard
stopcommands. The only way to bypass the block is through the "Emergency Recovery" steps below.
If you absolutely must access a blocked site, you must kill the service manually. This will leave your system in a blocked state and prevent the service from starting on the next boot until you clean it up.
- Stop
systemdfrom managing the service:sudo systemctl stop dsfree
- Find the Process ID (PID):
ps aux | grep dsfree - Kill the process:
# Replace <PID> with the number you found sudo kill -9 <PID>
- Restore your hosts file:
A backup of your original hosts file is at
/etc/hosts.dsfree.bak.sudo mv /etc/hosts.dsfree.bak /etc/hosts
To re-enable the service after a manual recovery, simply run sudo systemctl start dsfree.
To change the list of blocked sites, edit the domainsToBlock list in the main.go file, then rebuild and reinstall the binary.