Termux: Running Linux On Android

Hehheh, when I was a kid I didn’t know penguins will be so cute and cool to be friends with.

Termux is an emulator that runs a Linux environment on Android, you can install this application on your Android phones to access the CLI(Command line interface). You can write commands on it to access the file/directories of your computer system. Normally, computers uses Graphical user interface like Windows, which donot requires you to learn commands to operate your computer machine.

On Linux, you can operate your computer without depending on the mouse, it only requires you to have terminal and keyboard access.

The fun part is during this process you learn more about your operating system and the modules that build it up.

Android also uses the modified version of the Linux kernel so you can use Termux on Android easily.

Experimenting With Termux

Termux Emulator

Step 1: Upgrading the Termux packages: apt-get install

upgrade

Step 2: Now, if you want to install new packages:pkg install git

install packages

BUG founded!!!!

Finally, I found a Linux bug after a long time, let us see how this nasty kid can be fixed.

Unable to find the package git.

Debugger mind exploding!!!!

Seems like the mirrors can’t find the package git! Hmm or maybe the name of the package got changed? Oh if it did then the Termux latest version should have it so am I using the outdated version of Termux. Probably yes!

How to fix it??

  • First, try googling.
  • Then maybe by changing mirrors we can try running the command again.

Solution

apt update: Running this will update all the Termux packages that we previously didn’t update. Now retry running that command again.

bug resolved

Woah! It runs.

Moreover, after googling I found out that Termux on PlayStore is not updated so it will throw bugs in future. To use the latest Termux either one will have to download it from FDroid or GitHub.

Installing SSH

Want to do a git clone on your Android without relying on GUI? so install ssh so that you can git clone using ssh()secure shell). First, run apt update && apt upgrade.

updating

Second, pkg install openssh: It will install ssh on termux.

install ssh on termux

Setting Up Git On Termux

Update and upgrade all the packages of Termux: apt update && apt upgrade.

install ssh on termux

Install git and openshh: apt install git openssh

install ssh on termux

Setting the Git Storage

termux-setup-storage: Setting the storage for termux, it will ask you to access the storage of your mobile phone, allow to continue.

Connect to GitHub

We need to create the key-pair of SSH using the command: ssh-keygen -t rsa -C "YOUR_EMAIL_ADDRESS"

ssh

Generating a new ssh key

Follow this: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

Adding new ssh key to your GitHub account

Follow this: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

Log in to GitHub

ssh -T git@github.com

ssh

Finally, you have setup git on your termux, now you can upload files on github using your git account.

Cloning git files

You can run git commands git clone https://......

then clicking on ls will show you the downloaded files.

git files

Running .py scripts

Installing python:pkg install python

But then got another error that says:

    pkg install python
    Checking availability of current mirror: bad               Testing the available mirrors:
    [*] https://dl.bintray.com/termux/termux-packages-24: bad
    [*] https://grimler.se/termux-packages-24: bad
    [] https://main.termux-mirror.ml: bad                     [] https://termux.mentality.rip/termux-packages-24: bad
    Using fallback mirror: https://termux.org/packages         Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package python

Solution

Refer this: https://trendoceans.com/termux-package-management-issue/ Tried both solutions but still the errors persist.

.py script

Hence, the ultimate solution to this will be to switch to github repo or a fdroid repo that consist of latest termux.

If the errors got resolved for you then-

You can try running python script. Running python scripts: python3 filename.py.

Note- You cannot do high end task but you can run scripts and commands of linux on android.

Conclusion

Run linux commands on Android and learn android hacking if you like playing with the systems. To know more about termux and android hacking, visit: x.x.x.x blog(my upcoming blog).