Guide: Get started using termux

What’s included in this guide

This guide is intended to walk you through getting the most out of your Android phone using termux (a Linux terminal environment with most Linux packages available)

I’ll start by where to download and how to set it up and will also discuss building Android apps in termux! As well as using Claude Code to vibe code.

As I’ll describe soon, this is a full Linux environment, so I won’t be teaching you bash or Linux here. Just what’s necessary for using termux.

What is termux

Termux is a terminal emulator for Android. But unlike different simple Android terminal emulators, this doesn’t just give you a interface for running the Android built in shell (which is extremely limited) but rather comes bundled with bash (the default Linux shell) and much more.

Termux developers also maintain all basic (and not basic) Linux packages for termux! This means you can actually run almost any programming language and do almost anything you can do from a Linux computer right from your mobile. (Besides the phone hardware constraints obviously…)

Install termux

Download termux from GitHub or f-droid.
Do not use the one from Google play. (It’s no longer maintained and really backdated…)

termux packages manager

Like every Linux distro, termux has a package manager which is updated almost daily! It’s package manager is extremely simple and straight forward and almost the same as (and based off of) Ubuntu.

It uses pkg (or apt - works almost the same) and includes commands like

  • pkg update to update the repos (basically check for updates)
  • pkg upgrade for actually updating the packages
  • pkg info <pkg name>
  • pkg search <query>
    And some more. pkg help to learn more

After installing, you should run pkg update and pkg upgrade so you’re up to date.

I was gonna create a list of useful pkgs to install but I decided that that’s not useful… It totally depends on what you’re looking to develop/learn. But in general, most CLI programs that work on Linux you can install with pkg or apt on termux.

termux-api for Android integration

To get the most out of termux, there are a couple of interesting termux plugins. The one that’s the most useful is termux-api. It’s an app that lets termux deal more directly with Android native features. You can then use termux commands to interact with the Android system such as managing clipboard (what I use the most), sms (can use this for automations), calls and much more.

Download termux-api (not very large) from GitHub or from f-droid
Important: Use the same source you used for the main termux application (either GitHub or f-droid). Don’t mix and match.

Then in termux run

pkg install termux-api

You may have to launch the termux-api app once. Grant it permissions when it asks for them or install with adb install -g so it’s already all granted

Now you can use commands like termux-clipboard-get and termux-clipboard-set with pipes and redirects to copy command output or paste into file etc… To see a list of commands you can use with this check out termux-api wiki


Installing an AI CLI in Termux

Now that we’re done with the basics, we can discuss some extras. Running an AI in your terminal is both very powerful and very scary. Especially on Android (and especially especially if you’re rooted) - the AI might do stuff it’s used to doing on Linux which may mess you up. Know what you’re doing or don’t do it…

Claude Code is a great option and works amazingly in termux (in theory). But Claude code changed a short while ago from npm to native binaries which are compiled for glibc (regular Linux) and don’t run natively on Android which uses its own libc. This makes installing it the regular way fail.

To get it installed normally, someone made this repo. Very organized and makes everything with natively. GitHub repo

1 liner install:

curl -fsSL https://raw.githubusercontent.com/gtbuchanan/claude-code-termux/main/install.sh | bash

I’ve seen people say that codex also works here. I don’t have a codex subscription so I can’t test it. Feel free to figure it out…

Building apps in termux

This is where stuff can get complicated. When you look online you might find some old scripts and stuff but I never found something useful that explains how to actually build real Android apps in termux. Turns out it’s not that hard at all and I find it amazing that I can code it, build it, release it, install it and test it all on the same device that I use for everything else.

I’ll end this section with a really easy way to get it all set up

As you may be aware, there are 2 main ways to build Android apps:

  1. Java + xml
  2. Kotlin, Jetpack Compose and Gradle

While option 2 is considered the superior option today, it doesn’t play well with termux. (Hard to install and build can take pretty long). It’s not impossible (I’ve done it) but for termux I recommend option 1 (it’s good enough that for years all apps were written with it)

To do so you just gotta install the following

pkg install aapt2 ecj d8 apksigner zip

Since there are many steps and isn’t just the play button in Android studio, writing a build.sh file that goes through all the steps makes life much easier.

You’ll have to do a few things to get ready, a keystore file to sign APK files, and android.jar and framework-res.apk

You can do that all manually but I made a repo that automates exactly all this. I made it as a template I personally use to make my apps. But it includes a setup script to setup the environment. You can either use the template code or totally remove it, but the setup I think is very helpful.

All you do is clone the repo, run the setup script and then modify (or totally rewrite) the code and run build.sh

git clone https://github.com/flipphoneguy/app-template && cd app-template && chmod +x setup.sh && ./setup.sh

Enjoy termux!!

My main goal is to motivate you to use the terminal more and become productive on your Android device. If I missed anything or made a mistake or you have questions, please do comment in the comments thread.

Shoutout to @sh7411usa for the idea to write this up

If you found this helpful, please give it a :+1:. (Took some time to write this up)

Comments, questions and feedback in the main termux thread
https://jtechforums.org/t/termux-android-app

12 Likes