OESF Portables Forum

Model Specific Forums => Gemini PDA => Gemini PDA - Android => Topic started by: Pete G. on June 16, 2018, 07:32:56 pm

Title: Termux
Post by: Pete G. on June 16, 2018, 07:32:56 pm
[EDIT: Sorry -- didn't notice this topic already exists from earlier...]
 
One of the first things I installed was Termux, to give me a command-line terminal under Android.  I'm surprised how familiar it feels -- has all the basic stuff you'd expect in Linux.  Even installed stuff like Python and Ruby, and they look fine.

A couple of things I'd like to do, though, and haven't found a way, yet.  I have several machines on my LAN, which all have short and memorable names -- all stored in /etc/hosts files so apps "just use" them.  I haven't found a way to do that on the Gemini.  Termux provides a usr/etc, but putting a hosts there isn't recognized (by e.g. ssh).

What would also be really nice would be to have a shell-script in Termux invoke Firefox, say.  Anyone know if that's possible?
Title: Termux
Post by: KF6GPE on June 16, 2018, 09:05:32 pm
I'm not sure about the hostnames. That's a good question.

I seem to remember that maybe the api helpers package has something. Try
pkg install termux-api
termux-open-url <url>



Quote from: Pete G.
[EDIT: Sorry -- didn't notice this topic already exists from earlier...]
 
One of the first things I installed was Termux, to give me a command-line terminal under Android.  I'm surprised how familiar it feels -- has all the basic stuff you'd expect in Linux.  Even installed stuff like Python and Ruby, and they look fine.

A couple of things I'd like to do, though, and haven't found a way, yet.  I have several machines on my LAN, which all have short and memorable names -- all stored in /etc/hosts files so apps "just use" them.  I haven't found a way to do that on the Gemini.  Termux provides a usr/etc, but putting a hosts there isn't recognized (by e.g. ssh).

What would also be really nice would be to have a shell-script in Termux invoke Firefox, say.  Anyone know if that's possible?
Title: Termux
Post by: Murple2 on June 17, 2018, 06:49:28 am
Can you not just edit /system/etc/hosts? You'll need to remount system rw to make the change, assuming you have rooted your device that is.

edit:
or install and configure avahi on all you machines including gemini/termux.

or set up a dns server within your home network and do proper hostname resolving.
Title: Termux
Post by: gidds on June 17, 2018, 07:05:07 am
Quote from: Murple2
Can you not just edit /system/etc/hosts? You'll need to remount system rw to make the change, assuming you have rooted your device that is.

That's what I did.

You need to have flashed it with rooted Android.  Then you:
Code: [Select]
su rootand:
Code: [Select]
mount -o rw,remount /systemAfter that you can change /system/etc/hosts.  When done:
Code: [Select]
mount -o ro,remount /systemto make it read-only again.

But I have a related issue.  If I, as root, write a file, then my normal user can't read it — even if I add world read/write/execute permission, and/or set the file's owner and group to my normal user.

I hit this when editing the hosts file; the root user can't run vim, so I tried to copy the existing file somewhere my normal user could see and edit it.  But I couldn't find any way other than catting it to the screen and copy-and-pasting from there…

There's clearly something about the way file permissions are set up in Android that I don't understand!

I also don't understand why I can't write files to my SD card (/storage/8048014E3/) from Termux…
Title: Termux
Post by: Murple2 on June 17, 2018, 08:53:13 am
Quote from: gidds
But I have a related issue.  If I, as root, write a file, then my normal user can't read it — even if I add world read/write/execute permission, and/or set the file's owner and group to my normal user.

I hit this when editing the hosts file; the root user can't run vim, so I tried to copy the existing file somewhere my normal user could see and edit it.  But I couldn't find any way other than catting it to the screen and copy-and-pasting from there…

I was getting stuck with this as well but then I discovered  'tsu' - https://github.com/cswl/tsu/blob/master/README.md (https://github.com/cswl/tsu/blob/master/README.md)

I'm not sure if it will help with normal users reading root created files, but you will be able to run vim as root
Title: Termux
Post by: gidds on June 17, 2018, 11:55:28 am
Quote from: Murple2
I was getting stuck with this as well but then I discovered  'tsu' - https://github.com/cswl/tsu/blob/master/README.md (https://github.com/cswl/tsu/blob/master/README.md)

Ooh, that's worth knowing!  Many thanks.
Title: Termux
Post by: Pete G. on June 17, 2018, 02:55:17 pm
Quote from: Murple2
Can you not just edit /system/etc/hosts? You'll need to remount system rw to make the change, assuming you have rooted your device that is.

edit:
or install and configure avahi on all you machines including gemini/termux.

or set up a dns server within your home network and do proper hostname resolving.
That's the problem... I haven't quite dared to flash anything yet.  I'm all new to Android.

Don't know Avahi. Might be fun to set up my Pi as aDNS server!
Title: Termux
Post by: Murple2 on June 17, 2018, 04:23:53 pm
Quote from: Pete G.
Quote from: Murple2
Can you not just edit /system/etc/hosts? You'll need to remount system rw to make the change, assuming you have rooted your device that is.

edit:
or install and configure avahi on all you machines including gemini/termux.

or set up a dns server within your home network and do proper hostname resolving.
That's the problem... I haven't quite dared to flash anything yet.  I'm all new to Android.

Don't know Avahi. Might be fun to set up my Pi as aDNS server!

In that case I would definitely recommend the Pi route! I have dnsmasq set up on my home network. If using a Pi isn't the answer, then you are asking the wrong question!  

I've used avahi before and it isn't very hard to set up, but I don't like having to use domain suffix hostname.local rather than just hostname
Title: Termux
Post by: John Veness on June 17, 2018, 04:50:47 pm
You might find that your router can also act as a local DNS server.
Title: Termux
Post by: gidds on June 17, 2018, 05:20:46 pm
I went the hosts-file route so that my Gemini is still protected when I'm out and about, not only when I'm connected to my home network.

(I did the same on my MacBook Pro -- though there I have 700K entries in my hosts file, enough that Mac OS X was grinding to a halt, so I installed dnsmasq locally, and set localhost as the DNS server.  Anyone know how large the Android's hosts file can get before it starts to have a significant impact?)
Title: Termux
Post by: Pete G. on June 18, 2018, 06:39:27 pm
Quote from: Murple2
Quote from: Pete G.
i
. Might be fun to set up my Pi as a DNS server!

In that case I would definitely recommend the Pi route! I have dnsmasq set up on my home network. If using a Pi isn't the answer, then you are asking the wrong question!  
Well, that was easy...!     ...Actually not quite.  Installing dnsmasq on the Pi was a breeze,  but getting other boxes to use it took a while.    I set my router primary DNS to the Pi (Secondary left as my ISP), but I had difficulty in getting everyone else to see that.  In the end, I think I had to reboot the router and my laptop.  The Gemini seems to have sorted itself after the router reboot (as it had to restart the connection).

It's disconcerting, though, that I can find no information from the Gemini on how the network is set up.  No DNS IPs or anything.  (My Mint laptop -- with fixed IP DHCP -- is rather obscure, too.  resolv.conf is set to '127.0.1.1', so somehow the actual lookup must use some other mechanism.)

Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8', so I edited that to make dig use the router, but ssh still didn't rcognize names -- until I restarted the link.

Oh, well.  I think it's working now.
Title: Termux
Post by: vader on June 18, 2018, 11:00:35 pm
Quote from: Pete G.
Quote from: Murple2
Quote from: Pete G.
i
. Might be fun to set up my Pi as a DNS server!

In that case I would definitely recommend the Pi route! I have dnsmasq set up on my home network. If using a Pi isn't the answer, then you are asking the wrong question!  
Well, that was easy...!     ...Actually not quite.  Installing dnsmasq on the Pi was a breeze,  but getting other boxes to use it took a while.    I set my router primary DNS to the Pi (Secondary left as my ISP), but I had difficulty in getting everyone else to see that.  In the end, I think I had to reboot the router and my laptop.  The Gemini seems to have sorted itself after the router reboot (as it had to restart the connection).

It's disconcerting, though, that I can find no information from the Gemini on how the network is set up.  No DNS IPs or anything.  (My Mint laptop -- with fixed IP DHCP -- is rather obscure, too.  resolv.conf is set to '127.0.1.1', so somehow the actual lookup must use some other mechanism.)

Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8', so I edited that to make dig use the router, but ssh still didn't rcognize names -- until I restarted the link.

Oh, well.  I think it's working now.

8.8.8.8 = Google.
This is android's default. You can change this in network settings, but they don't make it obvious (wonder why)  You can also change it for termux by editing resolv.conf (as you did).
Title: Termux
Post by: Pete G. on June 19, 2018, 02:24:11 am
Quote from: vader
Quote from: Pete G.

Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8', so I edited that to make dig use the router, but ssh still didn't rcognize names -- until I restarted the link.

8.8.8.8 = Google
This is android's default. You can change this in network settings, but they don't make it obvious (wonder why)  You can also change it for termux by editing resolv.conf (as you did).

Yes. I actually use that DNS myself occasionally.  I have completely failed to find any such "network settings", though!  I was looking for half the day!  Hints, please...

[In passing. how do you insert emoticons here with the gemini?  I tap on one, and it checks a mark. but nothing goes into my text.]
Title: Termux
Post by: gidds on October 27, 2018, 12:08:55 pm
Quote from: Pete G.
Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8'
Erm, sorry if I'm missing something obvious (and for replying to an old topic!), but my Termux doesn't seem to have a resolv.conf file — I can't find that in /etc nor anywhere in the filesystem, nor even anything similar…

If I create an /etc/resolv.conf file, will it use that?  Or is some other set-up needed?
Title: Termux
Post by: Pete G. on October 28, 2018, 06:20:21 pm
Quote from: gidds
Quote from: Pete G.
Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8'
Erm, sorry if I'm missing something obvious (and for replying to an old topic!), but my Termux doesn't seem to have a resolv.conf file — I can't find that in /etc nor anywhere in the filesystem, nor even anything similar…

If I create an /etc/resolv.conf file, will it use that?  Or is some other set-up needed?
OK, I'm not at all sure of myself here, but my Termux has /data/data/com.termux/files/usr/etc/resolv.conf (a.k.a "~/../usr/etc").  This contains

  nameserver 8.8.8.8
  nameserver 8.8.4.4

so I assume that's being used.  I changed it to point to my ISP's nameserver and it still worked, but it also still works if I move resolv.conf right out of the way! (trying ping for example)  So I don't know if that file is relevant to anything at all.
(My Linux man page says that if that file doesn't exist it will use the "name server on the local machine".  How that works I have no idea, and ditto whether android/Termux does similar!)
Title: Termux
Post by: gidds on October 29, 2018, 08:29:32 pm
Quote from: Pete G.
OK, I'm not at all sure of myself here, but my Termux has /data/data/com.termux/files/usr/etc/resolv.conf (a.k.a "~/../usr/etc").
Hmmm; mine doesn't.  (Just 5 plain files and 4 dirs in there.)

I could try creating one, but I can't see how that would affect anything not run through Termux, which is a bit limiting.  As you indicate, there's probably something else going on!
Title: Termux
Post by: miked1541 on November 01, 2018, 01:37:03 pm
Quote from: gidds
Quote from: Pete G.
Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8'
Erm, sorry if I'm missing something obvious (and for replying to an old topic!), but my Termux doesn't seem to have a resolv.conf file — I can't find that in /etc nor anywhere in the filesystem, nor even anything similar…

If I create an /etc/resolv.conf file, will it use that?  Or is some other set-up needed?

I did not have this file either, but when I ran nslookup, it wanted me to install the package dnsutils, which had a dependency of resolv-conf.
I have the file there now (/data/data/com.termux/files/usr/etc), but changed the name server to something other than google.

Code: [Select]
nameserver 129.250.35.250
nameserver 129.250.35.251

Now, when I run nslookup, the default name server for lookups is 129.250.35.250:

Code: [Select]
$ nslookup
> www.oesf.org
Server:         129.250.35.250
Address:        129.250.35.250#53

Non-authoritative answer:
www.oesf.org    canonical name = vhost.ibiblio.org.
Name:   vhost.ibiblio.org
Address: 152.19.134.41

Perhaps the name lookup is specific to termux and not the entire OS.

miked1541
Title: Termux
Post by: Pete G. on November 02, 2018, 05:00:12 pm
Quote from: miked1541
Quote from: gidds
Quote from: Pete G.
Termux too seems a bit weird.  Its default resolv.conf uses '8.8.8.8'
Erm, sorry if I'm missing something obvious (and for replying to an old topic!), but my Termux doesn't seem to have a resolv.conf file — I can't find that in /etc nor anywhere in the filesystem, nor even anything similar…

I did not have this file either, but when I ran nslookup, it wanted me to install the package dnsutils, which had a dependency of resolv-conf.
I have the file there now (/data/data/com.termux/files/usr/etc), but changed the name server to something other than google.

Perhaps the name lookup is specific to termux and not the entire OS.

Ahah!  Yes. I find the same.  Perhaps that's why I have the file -- may have been asked to install it.  I don't think I  was using nslookup, but dig also  seems to use the file.

I'm not sure of the effect of different nameservers when I'm out and about.  The ones on  my home machines are my ISP's, but that doesn't seem appropriate  when I'm elsewhere...  Maybe I should just stick with Google.
Title: Termux
Post by: gidds on November 03, 2018, 03:04:03 pm
Quote from: miked1541
Perhaps the name lookup is specific to termux and not the entire OS.
Yes, that would make sense.

Quote from: Pete G.
I'm not sure of the effect of different nameservers
I'm no expert, but the factors I'm aware of:In addition to Google's name servers, there are many other (https://www.lifewire.com/free-and-public-dns-servers-2626062) public name (https://en.wikipedia.org/wiki/Public_recursive_name_servers) servers you (https://en.wikipedia.org/wiki/Neustar#DNS_Advantage) can use (https://en.wikipedia.org/wiki/Open_Root_Server_Network).  (I've been using OpenNIC (https://en.wikipedia.org/wiki/OpenNIC) and OpenDNS (https://en.wikipedia.org/wiki/OpenDNS) at home for many years, and they've always worked fine for me.  But I don't know enough to endorse them.)
Title: Termux
Post by: jovpov on December 05, 2018, 04:29:37 am
You have mentioned installing DNS on RPi, be sure to try pi.hole ! It will remove all ads for you