Termux: Android Terminal Emulator and Linux Environment

Key features include:

  • Security: SSH client for secure remote server access
  • Rich functionality: Choose between Bash, fish, or Zsh shells, and editors like nano, Emacs, or Vim
  • Customizable: Install packages using the familiar APT package management system
  • Explorable: Access the same packages available on Mac and Linux systems
  • Complete toolset: Latest versions of Perl, Python, Ruby, and Node.js available
  • Scalable: Connect Bluetooth keyboards and external displays
  • Development ready: C compiler with extensive libraries for building your own applications

Termux combiens powerful terminal emulation with a wide collection of Linux packages:

  • Enjoy bash and zsh shells
  • Edit files with nano and vim
  • Access servers via SSH
  • Compile code with gcc and clang
  • Use the Python console as a pocket calculator
  • Manage projects with git and subversion
  • Run text-based games with frotz

After installation, you'll have a minimal base system. Additional packages can be installed using the APT package manager, familiar from Debian and Ubuntu Linux distributions.

For more information, access the built-in help by long-pressing anywhere in the terminal and selecting the "Help" menu option.

  • Termux:API (free): Access Android features from Termux (read SMS, GPS, notifications, etc.)
  • Termux:Boot: Run programs at boot time
  • Termux:Float: Use Termux in a floating terminal window
  • Termux:Styling: Customize your terminal appearance (colors and fonts)
  • Termux:Tasker: Run Termux scripts from Tasker
  • Termux:Widget: Start Termux commands from the home screen

The environment includes a C clang compiler with many extension libraries, allowing you to compile your own applications. Termux also provides interpreters for various languages including Python, Java, Go, Rust, and others.

With tools like Midnight Commander file manager, Vim text editor, and SSH applications, Termux creates a comfortable workspace on Android devices, especially when paired with a keyboard.

While working in Termux resembles working on a Linux PC in many ways, Android limitations prevent full functionality. For example, USB port access and connected devices are not accessible, and the "top" command doesn't work on newer Android versions due to restrictions on the /proc filesystem.

PRoot can execute a command or start a shell session from a fake chroot. This is useful for virtualizing other operating systems' guest root filesystems. However, PRoot only virtualizes the root filesystem tree, not the entire operating system, so features like kernel module insertion won't work.

When using PRoot to virtualize a root filesystem, you may experience performance degradation, though it's faster than using an emulator.

First, unset LD_PRELOAD:

unset LD_PRELOAD

Then export the PRoot library:

export LD_PRELOAD=$PREFIX/lib/libtermux-exec.so

To reset LD_PRELOAD after PRoot usage:

unset LD_PRELOAD

You can restore LD_PRELOAD by:

  • Opening a new session
  • Re-exporting the path in the same session:
export LD_PRELOAD=$PREFIX/lib/libtermux-exec.so
  1. Install curl: pkg install curl
  2. Download the setup script: curl -OL https://raw.githubusercontent.com/TermuxArch/TermuxArch/master/setupTermuxArch.bash
  3. Run the setup script: bash setupTermuxArch.bash

Note: This installation requires approximately 1GB of free space in the user space, not on an external SD card.

Common uses for chroot include:

  • Reinstalling bootloaders
  • Rebuilding initramfs images
  • Upgrading or downgrading packages
  • Resetting forgotten passwords
  • Building packgaes in a clean chroot environment

Requirements for chroot:

  • Root privileges
  • Another Linux environment (LiveCD, USB flash drive, or existing Linux distribution)
  • Matching architecture environment
  • Required kernel modules loaded in the chroot environment
  • Swap enabled if needed: # swapon /dev/sdxY
  • Internet connection established if needed

Basic usage:

# arch-chroot /mnt

To exit chroot, simply use: # exit

  • xhost (or copying the secret from .Xauthority)
  • Using nested X services like Xnest or Xephyr
  • SSH with X11 forwarding: ssh -X
  • openroot when X service doesn't listen on TCP or SSH server isn't available
  • X11 VNC service connecting to an external VNC client
  • xchroot - an extended version of chroot for users and Xorg/X11 forwarding

Method 1: Through Android Settings

  1. Open Android Settings
  2. Go to Apps > Termux > Permissions
  3. Toggle the storage permission

Method 2: From Termux command line

termux-setup-storage

Grant the requested permissions when prompted.

  • App-private storage: Files in $HOME, accessible only from Termux
  • Shared internal storage: Device storage accessible by all apps
  • External storage: Files on external SD cards

Running termux-setup-storage creates a $HOME/storage directory with symlinks to various storage locations:


~/storage/shared    # Root of shared storage among all apps
~/storage/downloads # Standard directory for downloads
~/storage/dcim      # Traditional location for images and videos when device is mounted as camera
~/storage/pictures  # Standard directory for user-available pictures
~/storage/music     # Standard directory for audio files
~/storage/movies    # Standard directory for user-available movies
~/storage/external  # Symlink to Termux-specific folder on external storage (if available)
   

For read access, use termux-open from the termux-tools package:

$ termux-open -h
Usage: termux-open [options] path-or-url
Open a file or URL in an external app.

 --send               if the file should be shared for sending
 --view               if the file should be shared for viewing (default)
 --chooser            if an app chooser should always be shown
 --content-type type  specify the content type to use

$ termux-open hello.c
   

For write access, store files on the SD card. On Android Lollipop and above, this requires Termux to request read/write permissions for external data.

  • Nmap - Network exploration and security auditing
  • SQLmap - SQL injection detection tool
  • Lazymux - Penetration testing toolkit
  • Hydra - Password cracking tool
  • Metasploit - Penetration testing framework
  • Ngrok - Reverse proxy
  • Wifite 2 - Wireless network auditing tool

Tags: Android terminal-emulator Linux-environment PRoot chroot

Posted on Mon, 18 May 2026 18:36:10 +0000 by my_name