We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

Hosts file?

asked 2014-06-13 21:14:06 +0300

Killeri404 gravatar image

updated 2014-06-13 22:03:37 +0300

I want to access the hosts file for adblocking reasons just like you can on Windows / Android / Linux or basically any unix-like system.

I found the file in \etc\hosts but trying to replace it in file manager just gives me a permission denied error.

I assume it has to be done through terminal but I don't know how.

edit retag flag offensive close delete

2 Answers

Sort by » oldest newest most voted
6

answered 2014-06-13 22:20:14 +0300

incognito gravatar image

updated 2014-06-13 22:37:11 +0300

As you've already found out, the main hosts file is located at /etc/hosts, but keep in mind that there are two additional hosts files that are used by Alien Dalvik: /system/etc/hosts and /opt/alien/system/etc/hosts and you'll have to change those two as well if you intend to use your hosts settings with Android apps.

When it comes to changing them, since they are out of the regular user space you'll have to use Developer Mode and devel-su prior to modifying (or overwriting) them.

edit: I see you're not acquainted with terminal mojo, so here's a quick guide if you want to replace your hosts file (and don't want to use SFTP for transfer). First move your replacement hosts file via USB to, say, your Public folder exposed via MTP and then from the terminal do:

devel-su
cp /etc/hosts /etc/hosts.original
cp /system/etc/hosts /system/etc/hosts.original
cp /opt/alien/system/etc/hosts /opt/alien/system/etc/hosts.original
echo /etc/hosts /system/etc/hosts /opt/alien/system/etc/hosts | xargs -n 1 cp ~/Public/hosts

This will 'backup' all the original hosts files (as hosts.original in their designated directories) so you can get them back in case something goes wrong, and then replace them with the hosts file you've placed in the Public folder in your home.

As a rule of thumb, you should include in your new hosts file the lines from the original hosts file before replacing - that way you can be sure it won't mess up internal domain name spaces and such, but it isn't a requirement.

edit flag offensive delete publish link more
0

answered 2014-06-13 21:27:13 +0300

ApB gravatar image

Adblock works with the latest update so you will probably be ok woth that.

In order to use the terminal you have to activate developer mode. And then you can ssh into the phone to work from your computer instead of fingerterm.

edit flag offensive delete publish link more

Comments

Yes, I've figured out how to get the terminal to show up but how do I edit files in the root folder?

I want to replace "hosts" file in \etc\ with another version of the file but don't know how.

Killeri404 ( 2014-06-13 21:41:09 +0300 )edit

Install nano (text editor). Or copy the file to /etc

ApB ( 2014-06-13 21:54:43 +0300 )edit

That was the the question all the time..?

How do I copy the file there?

File Manager doesn't have permission to edit files there.

Killeri404 ( 2014-06-13 21:59:34 +0300 )edit

Sorry i thought you had basic command line skills in order to do something like that in linux.

If you have the file you can

1) Devel-su 2) rm /etc/hosts 3) mv thefile.txt /etc/hosts

ApB ( 2014-06-13 22:08:30 +0300 )edit

Thanks. :)

That blocked all the ads in native apps, but not Android apps?

Android apps must be on their own ecosystem, any idea where the android files are located?

Killeri404 ( 2014-06-13 22:30:01 +0300 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2014-06-13 21:14:06 +0300

Seen: 921 times

Last updated: Jun 13 '14