Search code examples
shellunixadbfile-permissions

How to adb chmod 750 on /sdcard using batch


I am learning adb. Can someone please tell me why below chmod command isn't changing permissions on the dir on /sdcard? It works fine in /data, but I'm trying to test in /sdcard. Thanks for any help.

adb shell su -c "chmod -R 750 /sdcard/path/to/dir"

Current perms are -rw- --- ---

I am running command from a batch script.

I am rooted and assume I don't need the su with sdcard, but have tried the following and they don't work either.

  • adb chmod -R 750 /sdcard/path/to/dir
  • chmod -R 750 /sdcard/path/to/dir
  • adb shell "chmod -R 750 /sdcard/path/to/dir"

Solution

  • This generally won't work. Android sdcard volume is normally mounted with "-noexec" flag to prevent exactly what you want to do from happening, no matter what FS type (vfat or ext2/3/4) it is.

    Since you have a rooted device, you may want to try remount sdcard volume without noexec flag - not sure if it work with FUSE filesystem drivers, though…