116

Whatever I type after adb shell it fails with Permission denied:

D:\android-sdk-windows\platform-tools>adb shell find /data -name *.db
find: permission denied

D:\android-sdk-windows\platform-tools>adb shell test
test: permission denied

D:\android-sdk-windows\platform-tools>adb remount
remount failed: No such file or directory

Any ideas?

Yves M.
  • 28,433
  • 22
  • 100
  • 135
Caner
  • 53,818
  • 35
  • 164
  • 173
  • Where are you trying to run the adb shell, in emulator or target device; if on target device you cant access the /data folder until unless you have root permission. – Vamsi Sep 13 '11 at 08:56
  • 32
    after `adb root` >> `adbd cannot run as root in production builds` what to do? – d.popov Nov 14 '12 at 23:24
  • 3
    I guess you need a rooted phone to be able to run that – Caner Nov 15 '12 at 09:00
  • yes, I know. But, as you see currently I do not have the reputation to comment the Author's post, but i had this problem, so the only way was to add new post, or to open duplicate thread, so I decided to add a post. – d.popov Jan 02 '13 at 10:19
  • 1
    the phone is was rooted, but something went wrong with the OS. It was freezing after loading the home screen on reboot. Anyway - nandroid flashing the phone with the stock ROM solved the problem. – d.popov Jan 02 '13 at 10:23

9 Answers9

156

According to adb help:

adb root                     - restarts the adbd daemon with root permissions

Which indeed resolved the issue for me.

Roman
  • 1,675
  • 1
  • 12
  • 12
56

Without rooting: If you can't root your phone, use the run-as <package> command to be able to access data of your application.

Example:

$ adb exec-out run-as com.yourcompany.app ls -R /data/data/com.yourcompany.app/

exec-out executes the command without starting a shell and mangling the output.

Fabian Zeindl
  • 5,732
  • 8
  • 52
  • 77
  • 10
    This only works for apps built to be debuggable - ie, you can use it for apps you are developing but it should not work for production releases of your app, or anyone else's apps. – Chris Stratton Nov 24 '17 at 16:46
  • 3
    This returns `run-as: Could not set capabilities: Operation not permitted` for me – Tom M Jan 08 '19 at 15:34
  • 1
    It works for emulator API 29, and don't forget to put `.debug` prefix to the end of app's package for debug apps: – ultraon Aug 05 '20 at 21:59
22

The reason for "permission denied" is because your Android machine has not been correctly rooted. Did you see $ after you started adb shell? If you correctly rooted your machine, you would have seen # instead.

If you see the $, try entering Super User mode by typing su. If Root is enabled, you will see the # - without asking for password.

wind
  • 245
  • 2
  • 2
6

You might need to activate adb root from the developer settings menu. If you run adb root from the cmd line you can get:

root access is disabled by system setting - enable in settings -> development options

Once you activate the root option (ADB only or Apps and ADB) adb will restart and you will be able to use root from the cmd line.

Macarse
  • 89,619
  • 44
  • 170
  • 229
  • 4
    If you can't see the 'Developer options' item in your Settings menu, see [this answer](http://stackoverflow.com/a/16866430/647939) for details of how to make it visible. (In short: Settings > About phone > Build number > Tap 7 times(!).) – Paul Whittaker Oct 20 '13 at 11:16
  • 1
    But once in, I don't see anything here! What should it say? – JohnyTex Oct 28 '14 at 14:00
  • 42
    **This option does not exist in stock Android builds** - if it exists at all, it would be confined to someone's aftermarket ROM. – Chris Stratton Nov 06 '14 at 18:14
  • Is there a way to do this without a GUI? I would guess there is an option for it in `/system/build.prop`, but I can't find it. – Jeroen Aug 16 '17 at 11:40
  • Where do I find the menu to look for settings? – martinkunev Dec 10 '17 at 16:34
6

None of the previous solutions worked for me but I was able to make it work using this command

adb shell "run-as com.yourcompany.app cat /data/data/com.yourcompany.app/shared_prefs/SHARED_PREF_PROTECTED.xml" > SHARED_PREF_PROTECTED.xml
Darien Alvarez
  • 153
  • 2
  • 10
  • This is great, however for binary files such as images or localDBs, the encoding seems to change. How would one copy binary files to windows? – raw May 14 '22 at 11:35
3

data partition not accessible for non root user, if you want to access it you must root your phone.

adb root not work for all product and depend in phone build type.

in new version on android studio you can explore /data/data path for debuggable apps.

Golil
  • 437
  • 3
  • 10
-4

Do adb remount. And then try adb shell

Pavankumar Vijapur
  • 1,176
  • 2
  • 10
  • 15
-5

Solution for me was (thx to David Ljung Madison post)

  1. Root the phone & be sure it is rooted
  2. Adb server (adbd) was not run as root so downloaded & installed the adbd insecure app
  3. Restart adb adb kill-server
  4. Run it & worked like a flower!
Community
  • 1
  • 1
Pipo
  • 4,013
  • 36
  • 39
-6

Run your cmd as administrator this will solve my issues. Thanks.

Kishan Oza
  • 1,665
  • 1
  • 13
  • 38