Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

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, 2011 at 8:56 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 2, 2013 at 10:19 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 2, 2013 at 10:23

According to adb help:

adb root                     - restarts the adbd daemon with root permissions

Which indeed resolved the issue for me.

You'll also need to enable root access for adb if you haven't done so already -- see @Macarse's answer. – Paul Whittaker Oct 20, 2013 at 11:12 This is not true. You just have to switch to the correct user. See my answer below: stackoverflow.com/a/38292436/342947 – Fabian Zeindl Jul 10, 2016 at 13:34

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.

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, 2017 at 16:46 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 5, 2020 at 21:59

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.

Once you have correctly rooted your machine, you will need to have enabled adb root access and be running adb in root mode before your su step can work - see @Macarse's and @Roman's answers. – Paul Whittaker Oct 20, 2013 at 11:21 @ChrisStratton You saved my life, I was also writting shell command from inside the adb shell already – Divyanshu Kushwaha Nov 24, 2017 at 10:48 I'm trying to see files in the Android simulator. I type 'su' after the '$' and it says: su: not found – Pete Alvin Dec 21, 2019 at 15:41 Nothing in the question mentions a rooted device. Why does this answer require the device to be rooted? – Andrew Koster May 26, 2021 at 16:39

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.

If you can't see the 'Developer options' item in your Settings menu, see this answer for details of how to make it visible. (In short: Settings > About phone > Build number > Tap 7 times(!).) – Paul Whittaker Oct 20, 2013 at 11:16 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 6, 2014 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, 2017 at 11:40

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
                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, 2022 at 11:35

The data partition is not accessible for non-root users, if you want to access it you must root your phone.

ADB root does not work for all product and depend on phone build type.

in the new version of android studio, you can explore /data/data path for debuggable apps.

update 2022

Android Studio new versions have some tools like Device Explorer and App Inspection to access application data. (app must be debuggable).

Confirm thepermission denied on Android emulator with API 30. I was working on getting on disk a sqlite file via $adb pull which also requires adb root – Gleichmut Oct 27, 2022 at 13:49 you cannot directly access to data folder or DB location from ADB in non-rooted device. but you can use Android Studio tools like Device Explorer or App Inspection to access debuggable app data like SQLite DB. – Golil Oct 29, 2022 at 4:26
  • Root the phone & be sure it is rooted
  • Adb server (adbd) was not run as root so downloaded & installed the adbd insecure app
  • Restart adb adb kill-server
  • Run it & worked like a flower!
  •