6

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...

1
  • Extremely bad idea to replace the default shell. If you want another shell, install it and then execute it when you like rather than replacing the system default shell Commented Mar 18, 2022 at 21:54

4 Answers 4

1

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.

3
  • is there another custom terminal not only adb?. If there is terminal which run specific binary which is located in my phone, the problem will be fixed easily. but I cannot find this custom terminal, can you give me some keyword about this? Commented Jun 11, 2012 at 2:48
  • i set permission in linux, and push this binary to my phone. but permission error is still occurred. I think permission is not file's property. thx Commented Jun 11, 2012 at 2:50
  • You may have some other problem beyond the file permissions, try pushing back a copy of the original android shell. Any terminal application you build from source should be able to be customized in what it launches, possibly some prebuilt ones even offer that as a menu option though I don't recall seeing that. Commented Jun 11, 2012 at 4:51
1

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
1
  • 1
    this cannot help, cause in my case, i cannot execute shell prompt by using adb shell (bash file's permission don't have excutable) I solve my problem by formatting whole firmware thank you to reply! Commented Aug 17, 2012 at 6:31
0

If you have recent versions of CWM installed you can be saved

a) adb reboot recovery (boot your phone into recovery)

b) in CWM recover mount /system partition ( using your phone ).

c) adb kill-server

d) sudo adb start-server

e) adb shell

f) Do your thing set your permission correctly

I was influenced by the answer here https://android.stackexchange.com/questions/38085/is-it-a-hard-brick/113507#113507?newreg=6e0c0c0be98349058d3e1668532cd7dc

0
adb shell su -c "your commands"

Not the answer you're looking for? Browse other questions tagged or ask your own question.