Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android adb shell permission denied

Tags:

android

shell

adb

I've suffered in using adb.exe.

I wanted to use adb.exe shell prompt same as bash, so I decided change the default bash binary (of course binary was cross compiled, and everything was perfect)

change bash binary is followed below order

  1. adb remount
  2. adb push bash /system/bin/

  3. adb shell

  4. cd /system/bin
  5. chmod 777 bash
  6. mv sh sh.bak
  7. ln -s bash sh

first change was successful, but problem is occurred when second try.

I push new bash binary, but I missed change bash's permission 777, and disconnect adb shell.

after

C:\Program Files (x86)\Android\android-sdk\platform-tools>adb.exe shell
- exec '/system/bin/sh' failed: Permission denied (13) -

C:\Program Files (x86)\Android\android-sdk\platform-tools>

Is there any smart idea to fix this permission problem?

please help me...

like image 953
Joonsung Kim Avatar asked Jun 11 '12 02:06

Joonsung Kim


2 Answers

If the device hasn't crashed completely (/system/bin/sh is a dependency for a lot of things - rebooting may not get very far!) and the system partition is still writable, you might be able to adb push a new copy of bash, where you have set the permission bits as desired on the host system before pushing it (you may have to use cygwin or even linux in order to have permission bits locally)

It sounds like the device is rooted, so you might be able to configure or customize a terminal emulator app to give you a session using the backup sh, run the backup sh again as root using some escalation tool, and then fix the problem.

If you have a modified recovery with adb, you could probably fix it from there by mounting the (normal) system partition manually.

Last resort would restoring from a vendor-signed vanilla image.

Hopefully you get un-stuck, but perhaps you've learned from this experience - changing the default shell is probably not a good idea. It would be better to load your custom shell under a different name and run it manually.

like image 156
Chris Stratton Avatar answered Oct 21 '22 11:10

Chris Stratton


A general solution for doing such things:removing system app and all.

adb shell
mount -o rw,remount -t yaffs2 /dev/block/mtdblk4 /system
cd /system/app/
rm maps.apk
mount -o ro,remount -t yaffs2 /dev/block/mtdblk4 /system
sync
reboot
like image 26
Ankit Jain Avatar answered Oct 21 '22 11:10

Ankit Jain