Edit the hosts file on JP2026

To prevent access to certain websites, I would like to edit the hosts file of the OS. What about the notation if I want to prevent calls to 123.abc, for example?

What would be used to work on it practically?

What should you never do in / with the file?

P.S.: There is a pi-hole running in my home network.

Cheers

As alternative, grab defender or host block from chum store.

3 Likes

Testing defender from Defender — SailfishOS:Chum, a Sailfish OS software repository by the community .

Cheers

It’s hosts-block btw.

The notation is very simple:

  • The first few lines should probably look like they do rn on your /etc/hosts; on my Xperia 10III it’s like this:

    127.0.0.1 localhost.localdomain localhost
    ::1 localhost6.localdomain6 localhost6 ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    
  • Then you need to decide if you want to direct these domains to 0.0.0.0 or 127.0.0.1. I read up on the difference long ago but forgot it now; anyhow I settled on 0.0.0.0 (this is configurable in hosts-block)

  • The rest of the file looks sth like this:

    0.0.0.0 gogetskill.in
    0.0.0.0 goggl.com
    0.0.0.0 goggle.com
    0.0.0.0 goggllemmeettiingnc.com
    0.0.0.0 gogifters-promocode-s.blogspot.com
    0.0.0.0 gogldha.shop
    etc.
    

Problem is that providers of hosts files often try to include the first few lines, but not specific to SFOS.

I use StevenBlack/hosts https://raw.githubusercontent.com/Steve
nBlack/hosts/master/hosts, but have to update manually.

Thanks guys. I’ll give it a try.

If you like a simple app that does all for you by just selecting sime lists, then go for (preferred :wink:)
Defender
This can also handle some cookie clean-up for you.
Or allow to add your own private block entries to hosts.editable

If you like similar way of adblocking via scrpting,
Then go for
Hosts-block

Or if you like to tinker on your own, just do so manually. Procedure is absolutely the same as on every network connected machine. Ohnonot already explained a bit above.
You may download (curl) adblocklists manually and add them to /etc/hosts…

1 Like