adb shell "operation not permitted" for every command

ealfonso picture ealfonso · Oct 1, 2013 · Viewed 58.6k times · Source

I recently did a factory reset of my android phone. Prior to the reset, I was able to install applications through adb install. The phone was not rooted.

After the factory reset, I mostly get "Operation not permitted" for nearly every command in adb shell (including ones that don't exist):

$ install
install: permission denied
$ push
push: permission denied
$ remount
remount: permission denied
$ su
su: permission denied
$ kmmsaldfmaldskfmlasdf
kmmsaldfmaldskfmlasdf: permission denied
$

Most of the PATH is unreadable to me (except for /system/bin and /system/xbin):

$ echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
$ ls /sbin
opendir failed, Permission denied
$ ls /vendor/bin
/vendor/bin: No such file or directory
$ ls /system/sbin/
/system/sbin/: No such file or directory

If I run adb root:

$ adb root
adbd cannot run as root in production builds

From my search (which has already robbed me of way more time than necessary), some pointers are to default.prop:

$ cat default.prop
#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.secure=1
ro.allow.mock.location=0
ro.debuggable=0
persist.service.adb.enable=1
$

But I have no write access to default.prop:

$ ls -l default.prop 
-rw-r--r-- root     root          118 1969-12-31 19:00 default.prop
$

I also seem unable to remount. I have been able to use adb successfully on the non-rooted device, why so much grief now? Has anyone come across this problem? My own phone is virtually unusable to me, and of course I am unable to do any development.

Trying to remount as rw:

$ mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
/dev/stl9 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=cp437 0 0
/dev/stl10 /cache rfs rw,nosuid,nodev,relatime,vfat,llw,gid/uid/rwx,iocharset=cp437 0 0
/dev/stl6 /mnt/.lfs j4fs rw,relatime 0 0
/dev/stl11 /data rfs rw,nosuid,nodev,relatime,vfat,llw,check=no,gid/uid/rwx,iocharset=cp437 0 0
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /
mount: Operation not permitted

My phone is a Samsung Galaxy Y, which could matter

Answer

Ted Hopp picture Ted Hopp · Oct 1, 2013

You need to issue commands like install from the PC command line:

C:\> adb install ...

instead of from within the adb shell. If that doesn't work, you may need to run

adb remount

and/or reboot your phone and/or reinstall the phone driver. See this thread for more info.

I've found that the path in an adb shell session can have all sorts of non-existent directories on it. I don't know why that is, but it normally doesn't screw up anything.