Author Topic: Termux  (Read 4794 times)

Pete G.

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
    • http://www.GoodeveCA.net
Termux
« 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?
« Last Edit: June 16, 2018, 07:45:08 pm by Pete G. »

KF6GPE

  • Newbie
  • *
  • Posts: 31
    • View Profile
Termux
« Reply #1 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?

Murple2

  • Full Member
  • ***
  • Posts: 137
    • View Profile
Termux
« Reply #2 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.
« Last Edit: June 17, 2018, 06:54:28 am by Murple2 »

gidds

  • Sr. Member
  • ****
  • Posts: 291
    • View Profile
    • http://
Termux
« Reply #3 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…
[blockquote]Andy/[/blockquote]
Psion 5mx –> Gemini (–> Cosmo)

Murple2

  • Full Member
  • ***
  • Posts: 137
    • View Profile
Termux
« Reply #4 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

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
« Last Edit: June 17, 2018, 08:54:58 am by Murple2 »

gidds

  • Sr. Member
  • ****
  • Posts: 291
    • View Profile
    • http://
Termux
« Reply #5 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

Ooh, that's worth knowing!  Many thanks.
[blockquote]Andy/[/blockquote]
Psion 5mx –> Gemini (–> Cosmo)

Pete G.

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
    • http://www.GoodeveCA.net
Termux
« Reply #6 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!

Murple2

  • Full Member
  • ***
  • Posts: 137
    • View Profile
Termux
« Reply #7 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

John Veness

  • Newbie
  • *
  • Posts: 6
    • View Profile
Termux
« Reply #8 on: June 17, 2018, 04:50:47 pm »
You might find that your router can also act as a local DNS server.

gidds

  • Sr. Member
  • ****
  • Posts: 291
    • View Profile
    • http://
Termux
« Reply #9 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?)
[blockquote]Andy/[/blockquote]
Psion 5mx –> Gemini (–> Cosmo)

Pete G.

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
    • http://www.GoodeveCA.net
Termux
« Reply #10 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.

vader

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Termux
« Reply #11 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).
« Last Edit: June 18, 2018, 11:02:04 pm by vader »

Pete G.

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
    • http://www.GoodeveCA.net
Termux
« Reply #12 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.]

gidds

  • Sr. Member
  • ****
  • Posts: 291
    • View Profile
    • http://
Termux
« Reply #13 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?
[blockquote]Andy/[/blockquote]
Psion 5mx –> Gemini (–> Cosmo)

Pete G.

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
    • http://www.GoodeveCA.net
Termux
« Reply #14 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!)