ADBash

A tool that allows quick connection to your device's ADB shell from the command line in Termux, with an additional option to launch a Bash shell directly within ADB Shell.

release date: 2025-10-05

view on GitHub
ADB Shell should be used with caution - after logging into the terminal you become the shell user (UID 2000) with elevated privileges. This user has access to many system commands (dumpsys, pm, some of the network monitors etc.) which, if used improperly, can damage important system components and/or other applications.

Use it wisely!

about

ADBash is a small Bash script made specifically for Termux on Android.
It connects Termux to the ADB host running on the same device (localhost / 127.0.0.1) and launches a full Bash session inside it.
The script is fully automated, minimal, and requires only a few basic tools to work.

In addition to automatically finding the ADB port and connecting to it, the script also allows launching a Bash shell within ADB, which in turn enables more advanced work with ADB, including creating more complex scripts, aliases, and functions.
Opis obrazka

features

The most important features of the script include:

- Connects Termux directly to the Android ADB host on localhost
- Opens a ready-to-use Bash shell inside the ADB session
- Automatically detects the local ADB port
- Works without root access
- Pure Bash with minimal dependencies
- Includes quick help and basic info screens
- Clean and simple design focused on automation
- Compatible with Android 10+ and Termux environments

example usage

Below is a demonstration showing the script’s behavior and output in -v mode, along with configuration setup and ADB startup:
The error visible in the recording shell: (...): Permission denied is not important. The Bash shell is copied directly from Termux and compiled for the Termux environment and its directory structure. This does not affect the shell’s functionality later on.

ADB pairing

The video below demonstrates how to pair Termux and ADB on my device running Android 15:
The ADB pairing step cannot be skipped. Without it, Termux will not be able to connect to the ADB Shell.

This process may look different on each device, so I am unable to provide instructions on how to perform it.
Pairing performed once is remembered and does not need to be repeated until the username or host name changes (for example, after reinstalling Termux).

compatibility

The script is compatible with Android 10+ devices supporting Wireless Debugging; with Termux version 0.118+/0.119+ and Bash 5.2+ (until any library changes occur, which I will monitor).

It requires a small number of additional tools:
- android-tools (adb) for initiating the ADB connection
- nmap for finding the ADB port
- bash for launching and creating a sub-shell within ADB