Compdigitec Labs

« | Home | »

Compiling GNU Bash 4.x for Android 2.x

By admin | September 4, 2011

Updated (2012-02-04): Updated to Bash 4.2 and included source code used to compile.

GNU Bash (the GNU Bourne Again Shell) is the standard shell on most desktop and server distributions of Linux. As a result, we can download bash source code and compile the Bash shell for use on Android devices to replace default /bin/sh and busybox sh. Since the Android NDK doesn’t support the full glibc library (it lacks /etc/group and friends), a small patch is required to compile Bash for Android 2.x devices (probably caused by changes since Android 1.5.x).

If you don’t feel like compiling from scratch you can download a pre-built version.


Once your prerequisites are set up and functioning properly (adjust all paths as required, such as ndk path):

export ANDROID_NDK=/opt/android-ndk-r7
export CC="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=${ANDROID_NDK}/platforms/android-5/arch-arm/"
patch -p0 < bash-android.patch
./configure --host=arm-linux --enable-static-link --without-bash-malloc --disable-rpath --disable-nls

Once that is done, open Makefile and add -static to CFLAGS so it looks like so: “-g -O2 -static”

file bash
# bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

You will find bash sitting in the folder. Now you can deploy it and try it through adb or something similar:

adb push bash /data/local/bin/bash
adb -d shell
$ /data/local/bin/bash
bash-4.2$ /data/local/bin/bash --version
GNU bash, version 4.2.0(2)-release (arm-unknown-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Of course, once you have it ready and set up you should probably create a “.bashrc” file to make the terminal a bit more bearable, if you wish to.

Bash running on Android 2.x

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Mobile | 12 Comments »

12 Responses to “Compiling GNU Bash 4.x for Android 2.x”

  1. Stephen Says:
    December 26th, 2011 at 23:06

    What version of BASH was this patch suppose to be run against?

    Running the patch against Bash 4.1 fails…

  2. admin Says:
    January 2nd, 2012 at 16:34


    Try bash-4.0.0(9) release as indicated in the screenshot above. I should probably try to find that tarball that I used…

  3. bob Says:
    February 2nd, 2012 at 17:37

    where is the source ???????

  4. admin Says:
    February 4th, 2012 at 17:38


    Post has been updated to a newer version of bash with sources 🙂

  5. 2.2 enough Says:
    March 16th, 2012 at 12:57

    Will it run on froyo 2.2? (it’s in uberoid 11 beta 3)

  6. admin Says:
    March 22nd, 2012 at 22:12

    @2.2 enough:

    It should run on all versions of Android, as far as I am concerned.

  7. nagaqq alternatif Says:
    September 8th, 2023 at 13:28

    … [Trackback]

    […] There you can find 58438 additional Info to that Topic: […]

  8. view Says:
    November 4th, 2023 at 06:06

    … [Trackback]

    […] Read More here on that Topic: […]

  9. เว็บตรง สล็อตออนไลน์ Says:
    November 5th, 2023 at 19:55

    … [Trackback]

    […] Find More Information here on that Topic: […]

  10. ซื้อหวยออนไลน์ Says:
    November 11th, 2023 at 11:23

    … [Trackback]

    […] There you will find 23806 additional Info to that Topic: […]

  11. buy adderall online Says:
    November 24th, 2023 at 05:31

    … [Trackback]

    […] Find More here to that Topic: […]

  12. คาสิโนออนไลน์ lsm99 Says:
    December 8th, 2023 at 21:45

    … [Trackback]

    […] Find More Info here to that Topic: […]