How To Run Linux On Android

How To Run Linux On Android

Reading time1 min
#Linux#Android#Mobile#UserLAnd#Termux#Proot

Mastering Linux on Android: Step-by-Step Guide to Running a Full Linux Environment on Your Device

Deploying a full Linux userland on Android is often considered niche, but for engineers, it can change the way you work remotely. Whether you need to compile code, leverage SSH tunneling, or use familiar CLI tooling on a phone or tablet, this workflow unlocks capabilities that typical mobile shells (or even laptops) can’t match.

Why Even Bother Running Linux on Android?

  • Field debugging: Connect to network hardware, run nmap or tcpdump, clone a Git repo, or quickly patch a script with vim—all from a phone.
  • Security workflows: Use Kali tools or OpenVPN in environments where laptops draw attention.
  • Portable experimentation: Test scripts, run Python environments, or automate AWS CLI tasks outside the desktop/laptop context.

These gains come at some cost: touch input can slow you down and your battery will take a hit. But for many, the trade-off is worthwhile.


Prerequisites

  • Android device: Android 7.0 (API 24) or later is required. ARM64 CPUs have best support. At least 2GB free storage.
  • Reliable WiFi (you’ll download distro root filesystems several hundred MBs in size).
  • Bluetooth/USB keyboard and mouse recommended. Desktop-class typing is unrealistic on mobile keyboards.
  • Optional: root access is not required or recommended here; all methods below are userland.

Two Approaches

ApproachGraphical AppsComplexityStorage Overhead
UserLAndYes (VNC)Low~2GB+
Termux+proot-distroPartial (XSDL)Moderate<2GB

Note: Rooted methods (e.g., full chroot with LoopDevice an Linux Deploy) exist but are excluded—breaks SafetyNet, voids warranties, raises risk.


Option 1: Install Linux via UserLAnd

UserLAnd provides an abstracted, rootless layer for deploying entire Linux filesystems (Ubuntu, Debian, Alpine, Kali) on Android. Quick to set up; good for graphical and CLI workflows.

Steps:

  1. Grab UserLAnd from Google Play.
  2. On first launch, select your preferred Linux distribution (Ubuntu 22.04 LTS is stable).
  3. Set UNIX username/password, VNC password.
  4. Download will fetch and unpack the rootfs (1-2GB).
  5. Select a session—choose SSH (for command-line) or VNC (graphical via localhost:localhost:5999).
  6. Use built-in terminal or connect an external app (e.g., JuiceSSH, bVNC).

Get started, for instance, by installing classic tooling:

sudo apt update && sudo apt upgrade -y
sudo apt install git vim htop -y

Known issue: Filesystem performance can lag vs. bare metal (overlay storage in Android isn't fast). Expect occasional slowdowns, especially with large package installs.


Option 2: Termux + proot-distro

Termux isn’t just a terminal emulator—it packages a real Linux userland, custom-built for Android’s unique security model.

Recommended Termux version: 0.118.x+ (install from F-Droid; Play Store versions are often outdated or missing required APIs).

Setup:

pkg update
pkg upgrade
pkg install proot-distro

List available distros:

proot-distro list

Example output:

Available distributions:
- alpine
- debian
- fedora
- ubuntu

Install Ubuntu (22.04 as of writing):

proot-distro install ubuntu
proot-distro login ubuntu

Now inside $HOME/ubuntu-fs, isolated and rootless. The environment supports apt, and you can install nearly all CLI utilities.

Practical Example: Set Up a Python Virtual Environment

sudo apt update
sudo apt install python3-venv -y
python3 -m venv ~/devvenv
source ~/devvenv/bin/activate
pip install requests

Gotcha: Networking inside proot is bridged by Android’s user space. In rare cases, VPNs or corporate firewalls can cause DNS or routing anomalies; test ping 8.8.8.8 if apt stalls.


Running Graphical Linux Applications

UserLAnd: Native VNC integration. Install a VNC client (e.g., bVNC). Inside the UserLAnd session:

sudo apt install firefox

Launch via VNC session, with DISPLAY env set automatically.

Termux: Needs a companion X11 server. XServer XSDL is the most stable option.

  1. Install XServer XSDL from Play Store.
  2. In Termux session, forward display:
    export DISPLAY=:0
    
  3. In proot-distro environment, install and launch GUI app; for example:
    sudo apt install xterm
    xterm
    
    XServer XSDL should display it. Occasionally, font rendering issues crop up—adjust XServer settings if necessary.

Side Note: X11 performance is adequate for lightweight editors (leafpad, xterm) but poor for browsers or heavy IDEs. Don't expect miracles.


Customizing and Maintaining Your Linux-on-Android Setup

  • Install frequently-used developer tools:
    sudo apt install make gcc python3-pip openssh-client -y
    
  • Configure persistent dotfiles: Carry your .bashrc, .vimrc, or SSH keys in a private git repo and clone during setup. Symbolic links can be unreliable on some filesystems—copy actual files instead.
  • Backup: For Termux, periodic tar backups of $HOME and the Linux rootfs are wise. UserLAnd’s built-in backup/export is less flexible.

Practical Considerations

  • Battery drain during package installs or CPU-intensive workloads is significant. Avoid long compiles on battery power.
  • Storage: Uninstall unused distros to conserve space; these rootfs directories grow quickly.
  • Updates: Android kills background processes aggressively. Save your work before switching apps.
  • Error message worth noting: If you see proot warning: can't stat..., permissions in Android's scoped storage may be at fault—move install locations or check app permissions.

Summary

There’s no one-size-fits-all solution. For a simple graphical or introductory workflow, UserLAnd suffices. Advanced users willing to tinker should consider Termux + proot-distro for speed and flexibility. Most engineers will swap methods based on the use case.

Known alternatives: Linux Deploy (root required), Andronix (script-driven setup), but for enterprise or BYOD scenarios, stick to rootless options.

Problems will come up; workarounds exist. Concerns about performance or specifics? Search error logs, the Termux wiki, or UserLAnd issues tracker—most edge cases have been documented.

Realistically, a Linux-in-your-pocket setup won’t replace a laptop, but for mobile fixes, emergency troubleshooting, or portable demo environments, it remains a highly effective tool.


If you run into Permission denied or odd failures, check your Android's app permissions and storage settings first—about 30% of reported issues trace to them, not the Linux environments themselves.