Android > Androidのシェルをbashに変更

bashバイナリをダウンロード


pub.mzet.net から bash をダウンロード

pc$ wget http://pub.mzet.net/bash

android にコピー


pc$ cd /opt/android-sdk-linux/platform-tools/
pc$ sudo ./adb start-server
pc$ ./adb push bash /mnt/sdcard/bash

/system/bin にコピー


pc$ ./adb shell
$ su
# mount | grep system
/dev/block/mmcblk0p25 /system ext3 ro,relatime,errors=continue,barrier=0,data=ordered 0 0
# mount -ro remount,rw /dev/block/mmcblk0p25 /system
# mount | grep system
/dev/block/mmcblk0p25 /system ext3 rw,relatime,errors=continue,barrier=0,data=ordered 0 0
# cd /system/bin
# cp /mnt/sdcard/bash ./
# ls -l /system/bin | grep bash
----rwxr-x    1 0        0          2569259 Nov 14 11:54 bash
# chmod 0755 bash
# ls -l /system/bin | grep bash
-rwxr-xr-x    1 0        0          2569259 Nov 14 11:54 bash
# exit
$ exit

ログインしなおして、確認


pc$ ./adb shell
bash-3.2$ bash --version
GNU bash, version 3.2.0(7)-release (arm-none-linux-gnueabi)
Copyright (C) 2005 Free Software Foundation, Inc.
bash-3.2$ rm /mnt/sdcard/bash

bash_profile を書く


bash-3.2$ vi bash_profile
PATH=/sbin:/system/xbin:/system/bin
if [[ ${EUID} == 0 ]] ; then
  PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
  PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi

ログインしなおして確認

sh-3.2$ exit
pc$ ./adb shell
localhost / $
最終更新:2015年11月14日 21:16