Introduction

[UPDATE]:I wrote a new document with much more information on how I use Linux on Android! (2025.07.03)

This document shows you how to install Alpine Linux on Android based devices in a userspace chroot called proot.

To be honest, we are not installing Linux here. Android provides the Linux Kernel. We are just installing a Linux distribution’s filesystem tree and are then “prooting” to it.

Since this site shows you are very raw way on how to do it, I recommend to use PRoot Distro for setting things up fast!

I know there are other apps and scripts available in F-Droid and PlayStore (AnLinux, UserLAnd, etc.), but this document just wants to show you how easy it is to do it by yourself, only using Termux as Frontend/TUI.

Keep it simple! ;)

I have this running on two very different devices, a tablet and a phone. The tablet I am using is a Samsung SM-T585 (LTE/Wifi) with stock Android, also known as Samsung Galaxy Tab A 2016 (10.1, LTE). The phone I am using is a Google Pixel 5 with GrapheneOS installed.

This is a work in progress actually… but it works!

Installation

Requirements

  • A device with armv7 CPU support (aarch64 should work too but I have no device to test it)
  • The Termux App installed on your device and configured as descriped in the documentation

Open Termux!

Update Termux

Since this document always refer to the latest updates of Termux, I always recommend to update to the latest packages available.

 pkg upgrade 

Prepare Termux for the Alpine installation

 apt install proot mkdir alpine cd alpine 

Get Alpine Linux minirootfs and extract the archive

 wget https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/armv7/alpine-minirootfs-3.20.3-armv7.tar.gz tar -xvf alpine-minirootfs-3.20.3-armv7.tar.gz 

PRoot!

 export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH export TMPDIR=/tmp unset LD_PRELOAD HOME=/root proot -r ./ -0 -w / -b /dev -b /proc -b /sys /bin/sh 

Configure the PRoot environment

 echo "nameserver 9.9.9.9" > /etc/resolv.conf echo "nameserver 149.112.112.112" >> /etc/resolv.conf 

The nameservers are provided by Quad9. Just change them to your favorites…

You could step over to the “Where to go from here?” section as everything is ready to go. The next section is just to show you how I set up my environment properly to fit my needs. Since my preferred Shell is the Z shell (Zsh), I mostly set up my shell environment.

Get your personal configuration (optional)

This section is an example on how I configure my environment.

Install and configure some addional packages

 apk add git openssh vim zsh zsh-completions zsh-vcs git config --global init.defaultBranch main ssh-keygen 

Add the content of ~/.ssh/id_*.pub to Forgejo, Gitea, GitHub, etc…

Get some configuration files

 cd ~ wget https://hanez.org/files/home.7z 7z x home.7z touch .penv /bin/zsh 

Edit /etc/passwd to set the default shell from /bin/sh to /bin/zsh for all users

 sed 's:/bin/sh:/bin/zsh:' -i /etc/passwd 

Where to go from here?

Exit the environment and “proot” again…

Just hit Ctrl+D! If you have executed /bin/zsh during this setup, you need to hit Ctrl+D twice.

Usage

Open Termux!

In Termux

 export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH export TMPDIR=/tmp export ZSH=/root/.zsh/oh-my-zsh # (optional) unset LD_PRELOAD 

PRoot!

 HOME=/root proot -r ./alpine -0 -w / -b /dev -b /proc -b /sys /bin/sh 

Or in my case (optional)

 HOME=/root proot -r ./alpine -0 -w / -b /dev -b /proc -b /sys /bin/zsh 

Inside the PRoot environment

Have fun! :)

Links

  • Alpine Linux - A security-oriented, lightweight Linux distribution based on musl libc and busybox
  • Android - A mobile operating system based on a modified version of the Linux kernel and other open-source software
  • AnLinux - Run Linux on Android without root access
  • F-Droid - An installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform
  • GrapheneOS - The private and secure mobile operating system with Android app compatibility
  • PRoot - A user-space implementation of chroot, mount –bind, and binfmt_misc
  • PRoot Distro - A Bash script wrapper for utility proot for easy management of chroot-based Linux distribution installations
  • Quad9 - A free service that replaces your default ISP or enterprise Domain Name Server (DNS) configuration
  • Termux - An Android terminal emulator and Linux environment app that works directly with no rooting or setup required
  • UserLAnd - An easy way to run a Linux distribution or application on Android
  • Zsh - A shell designed for interactive use, although it is also a powerful scripting language

Comments