Introduction

Termux is a terminal emulator and Linux environment that runs on Android without rooting. It gives you access to a powerful package manager (pkg), a full Bash shell, and a curated collection of Linux tools—all from your phone or tablet. For developers, Termux turns a mobile device into a portable dev workstation: you can write scripts, run Python or Node.js, compile C programs, manage Git repos, and even SSH into remote servers.

Getting Started

Installation

  1. Open the Google Play Store or F-Droid and install the Termux app.
  2. Launch Termux. The first run will populate the $HOME directory and set up the default package repositories.
  3. Update the package index:
apt update && apt upgrade -y 

Tip: Use apt or its wrapper pkg interchangeably; pkg adds colour and shortcuts.

Core Package Management

Termux uses the same apt backend as Debian/Ubuntu, but packages are compiled for Android's ARM or x86_64 architectures.

Installing Common Tools

pkg install git python nodejs curl wget neovim tmux openssh 
  • git – version control
  • python – scripting and data work
  • nodejs – JavaScript runtime
  • neovim – lightweight editor
  • tmux – terminal multiplexer for persistent sessions
  • openssh – SSH client/server

Searching and Removing

pkg search <keyword> pkg uninstall <package> 

All packages live under $PREFIX, which resolves to /data/data/com.termux/files/usr.

Writing Your First Script

Create a file called hello.sh:

echo "#!/data/data/com.termux/files/usr/bin/bash" > hello.sh chmod +x hello.sh cat >> hello.sh <<'EOF' echo "Hello from Termux!" EOF ./hello.sh 

The shebang points to the Bash binary inside Termux, ensuring the script runs regardless of the Android shell.

Python Development

Termux’s Python package ships with pip. Install a virtual environment to keep dependencies tidy:

pip install --upgrade pip setuptools wheel pip install virtualenv virtualenv venv source venv/bin/activate pip install requests beautifulsoup4 

Now you can write a quick scraper:

cat > scraper.py <<'PY' import requests, bs4, sys url = sys.argv[1] resp = requests.get(url) soup = bs4.BeautifulSoup(resp.text, 'html.parser') print(soup.title.string) PY python scraper.py https://dev.to 

All of this runs on a phone with the same speed you’d expect from a low‑end laptop.

Node.js and npm

Node.js works out of the box. Install a project globally or locally:

npm init -y npm install express cat > index.js <<'JS' const express = require('express'); const app = express(); app.get('/', (req, res) => res.send('Hello from Termux!')); app.listen(3000, () => console.log('Listening on 3000')); JS node index.js & 

You can reach the server from the same device via http://127.0.0.1:3000 or from another device on the same Wi‑Fi network using the phone’s IP address.

Using SSH

As a Client

ssh user@remote-host.com 

The first time you connect, accept the host key and you’re in.

As a Server

apt install openssh passwd # set a password for the Termux user sshd 

Find your device’s IP with ip addr show wlan0. Then from a laptop:

ssh $(whoami)@<phone-ip> 

You now have a full remote shell on your Android device.

Persistent Sessions with tmux

tmux lets you detach from a session and re‑attach later, perfect for long builds or monitoring logs.

tmux new -s dev # work inside the session Ctrl‑b d # detach tmux attach -t dev # re‑attach 

Even if Termux is killed in the background, the tmux server stays alive as long as the process isn’t killed.

GUI Apps via XServer XSDL

Termux can launch X11 programs that display on an external X server app like XServer XSDL.

  1. Install XServer XSDL from the Play Store.
  2. In Termux, set the display:
export DISPLAY=:0 apt install x11-repo pkg install xorg-xhost xfce4-terminal 
  1. Start XSDL, note the display number (usually :0), then launch a GUI app:
xfce4-terminal & 

You now have a full desktop‑style terminal on your phone screen.

Advanced Tips & Tricks

  • Storage Access: Run termux-setup-storage to create a ~/storage symlink to shared media directories (Downloads, DCIM, etc.).
  • Git Credential Helper: Cache your credentials for faster pushes:
git config --global credential.helper 'cache --timeout=3600' 
  • Compile Native Code: Install clang and make to build C/C++ projects directly on the device:
pkg install clang make 
  • Battery Optimizations: Add Termux to the Battery optimization whitelist, otherwise Android may kill the process when the screen is off.
  • Backup Packages: Export the list of installed packages with:
dpkg --get-selections > pkg-list.txt 

Later, restore with dpkg --set-selections < pkg-list.txt && apt-get dselect-upgrade.

Real‑World Use Cases

  1. On‑the‑Go CI Runner – Use Termux to run lightweight CI jobs (e.g., linting, unit tests) while commuting.
  2. Network Diagnostics – Tools like nmap, tcpdump, and wireshark (via tshark) work directly on the mobile network interface.
  3. Learning Linux – Students can practice Bash scripting without a dedicated laptop.
  4. Remote Development – Pair Termux with VS Code’s Remote SSH extension to edit files on your phone from a desktop IDE.

Conclusion

Termux bridges the gap between mobile and desktop development. By leveraging a familiar Debian‑style package manager, a full Bash environment, and support for languages like Python, Node.js, and C, you can turn any Android device into a capable dev workstation. Whether you’re debugging on a remote site, need a quick scripting sandbox, or want to run a persistent SSH server, Termux has you covered. Install it, explore the packages, and start hacking on the go – the only limit is your imagination.