I recently came across Termux, which allows you to have a terminal right on your Android device, without the need of being rooted. So let's play with it and see how far we can go..
First thing, install the Termux app on your Android device, from https://play.google.com/store/apps/details?id=com.termux and open it.
Now, you can install most of Ubuntu/Debian packages you'd think of. I've initially installed:
pkg install nano vim htop
You can even use apt install
, as you'd do on Ubuntu/Debian.
Let's run htop
:
Run Golang apps on your device
Let's say you want to fetch and build a go app.. wait, wha'..?! Yeah, see below:
pkg install git golang
Remember, your home user dir in the Termux env is /data/data/com.termux/files/home
. So now we need to set the GOPATH
, just run export GOPATH=/data/data/com.termux/files/home/go
.
To confirm the installation, run go env
:
Let's fetch gin and run an example:
go get github.com/gin-gonic/gin
cd /data/data/com.termux/files/home/go/src/github.com/gin-gonic/gin/examples/basic
go run main.go
Now open your browser and go to http://127.0.0.1:8080/ping
, you should see a pong
response.
Awesome! Just imagine what you can do with this, like private deployed Go apps on your Android device, no need for an external server!
Run an SSH server
Let's say you got bored of typing on your device's virtual keyboard, you can just install a SSH server and connect to it from your desktop machine.
Run in Termux:
pkg install openssh
Let's suppose both the mobile device and the desktop machine are on the same network, connected via WiFi.
Install your desktop's ssh public key in /data/data/com.termux/files/home/.ssh/authorized_keys
. One way of doing, if you have Telegram installed on your desktop and mobile device, is pasting the contents of ~/.ssh/id_rsa.pub
onto your Telegram personal account on the desktop and then copying that back on the mobile device in the clipboard. Then in Termux, just run nano /data/data/com.termux/files/home/.ssh/authorized_keys
, paste the key, save the file and that's it.
Find your mobile device's local IP, run in Termux: ifconfig
, should be something like 192.168.0.100
.
Now run the SSH server in foreground, so you can see the connections, run in Termux: sshd
.
On your desktop machine, in the terminal, run ssh root@192.168.0.100 -p 8022
. You should now be on your mobile device's terminal :)
Go crazy with Termux!