I have a Android phone connected to my Linux's usb port. But I cannot access its sdcard
directory in adb shell. I tried rebooting, reinserting the device, but it never worked. Besides, it's strange that I don't have su or sudo in my adb shell, so I am prohibited from doing
sudo mount -o remount rw ...
as well. Any workaround?
If you are trying to do this in a hardware device (not emulated) you will need to root your Phone to change the permission of the folders.
See this link: http://www.androidcentral.com/root
Or this (Framaroot): http://forum.xda-developers.com/showthread.php?t=2130276
Hope it helps
Related
My phone Samsung Galaxy S5 mini is rooted. I'm trying to pull files from /data/data/myapp.package/ to folder on my PC.
adb pull /data/data/myapp.package E:\myapp\myapp.package
it gives me this error
adb: error: failed to copy '/data/data/myapp.package' to 'E:\myapp\myapp.package': Permission denied
I found many questions like mine but no answer solved my problem. Some suggested to execute this command adb root before pulling files. Some suggested to install adbd insecure app to enable root access. In fact after installing that app, phone disappeared from adb terminal. Both solution didn't work for me.
BTW, I can copy files using cp command from adb shell but I have to copy files to sdcard and then pull from sdcard. I'm looking for solution which allows me to copy files directly from /data/data/myapp.package to my PC
Any solution?
For your adb to be able to access /data/data directly (for adb pull), your adbd should be running as root - which can generally be done by adb root command.
adb root would not work on commercial devices like Samsung Galaxy S5 mini as commercial devices have ro.secure=1, i.e., the adbd can't be restarted as root due to a check of property called ro.secure. adbd insecure app circumvents this and restarts adbd in root mode to enable adb pull, etc. to work.
In short, if adbd insecure app doesn't work for you, it's not possible to do adb pull from /data/data in your existing ROM. It might be possible if you change the ROM / do some boot.img tweaks, but I would probably suggest trying latest version / different versions of adbd insecure app before going for ROM changes.
Read more on rooting here.
First you need to hit these two command from command line
adb root
adb remount
then
adb pull /data/data/myapp.package E:\myapp\myapp.package
This is my example pulling DB file from the root directory
adb -e shell "run-as com.example.project cp /data/data/com.example.project/databases/project.db /sdcard"
The key is run-as
Here's a one-liner that lets you pull a file without installing anything else and without having to copy it to a public location on the device to then pull it to your computer:
adb exec-out su -c cat /data/data/myapp.package/my_file.apk > my_file.apk
What this does:
adb exec-out runs a command and outputs the raw binary output
su -c runs the provided command as root
cat <file> prints out the file contents
> <file> redirects the output from adb (i.e. the raw file contents) to a local file.
I'm trying to use the Android Adb Command Prompt to copy a folder inside the app container to a local Windows folder. The device is running Android 5.1.1 and is not rooted.
adb pull or cp aren't working. How can I copy a folder?
The following approaches aren't working:
Approach 1
adb shell
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
error: device not found
Inside the shell you can't see to do adb pull. See here.
Approach 2
DDMS can't access the data folder.
Approach 3
adb shell
run-as DroidSample.DroidSample
cp /files/MetroLog/MetroLogs/ C:/temp/test
cp: /files/MetroLog/MetroLogs/: No such file or directory
Approach 4
adb shell
run-as DroidSample.DroidSample
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs/ C:/temp/test
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs is a directory (not copied).
This is also not working.
Approach 5
adb shell
run-as DroidSample.DroidSample
chmod 777 /files/MetroLog/MetroLogs
exit
exit
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
adb shell run-as DroidSample.DroidSample
chmod 700 /files/MetroLog/Metrologs
remote object '/data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs' does not exist
So also this isn't working.
Approach 6
adb shell
mkdir /sdcard/tmp
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs /sdcard/tmp
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs: Permission denied
This is also not working.
Approach 7
The only thing which half work is this
adb exec-out run-as DroidSample.DroidSample cat "files/MetroLog/MetroLogs/Log - 20160509.log" > C:/temp/test/test.log
But here I don't get the original file and I also have to know the exact file name. Additionally, that I loose line breaks and I have to do this for each file. Not that what I want.
So I'm running out of ideas. How can I access the internal stored files and copy them over?
You have almost solved the problem. As the storage of this kind is secured, you need to do one additional step. You need to copy the file from secured location to sdcard of the device. And then you can copy it anywhere via usb or android pull. Here are the command sequence I executed successfully.
adb shell
run-as DroidSample.DroidSample
cd shared_prefs
cp DroidSample.DroidSample_preferences.xml /sdcard/DroidSample.DroidSample_preferences.xml
exit
exit
adb pull /sdcard/DroidSample.DroidSample_preferences.xml C:/test/
That's it.
And I really appreciate the way you posted your question. Best of luck.
You're trying to gain read access to /data partition on actual android device. Such thing is not possible without root access, even if the app folder is yours. For the reason that permissions to read /data partition are not granted and cannot be granted, unless you're using an emulator. On emulator, which by default is with admin privileges for developer, you can access the data partition to read and write. On actual device you cannot. Not with adb, not with DDMS.
So basically speaking, anything that requires access to those files under /data is not going to work. Whether you sue cp command or pull command. The moment your kernel reads the beginning of your path which starts with /data/... it says: Oops, no can do.
You are trying to access /data folder of android device which is not accessible in unrooted device.
I want to push some apk file to sd card, then to /system folder. I tried the following commands in order:
adb shell
su
mount -o rw,remount /system
adb push /data/app/com.project.android.xxx-2.apk /sdcard
But the last line always results in device not found error. I have even tried with system folder directly as, adb push /data/app/com.project.android.xxx-2.apk /system/app, but it gave me the same error. I have also tried to execute this line before push command:
chmod 644 /sdcard
But that didn't solve the push command problem.
My device is rooted.
Device driver is updated.
My device has sd card.
USB debugging mode is enabled.
When I write adb devices I get my device name.
What is causing this error, and how can I solve it?
You're executing adb push being already shell-ed into the device. By doing that you start another adb server on the target device now (not on your host machine), which is scanning ports in some range looking for devices attached. Since no device is found (attached to the target device) you get error: device not found. For the kind of task you're trying to achieve no need to use any of adb commands within shell.
Try either mv or cp command once you shell-ed in. For example (remounting part skipped):
adb shell
cp /data/app/com.project.android.xxx-2.apk /sdcard
I am using adb on Android phone.
I did./adb shell
and I can see the folders inside the phone
I type cd /sdcard
but it said permission denied.
I can't use su or sudo to make myself root.
How can I make myself as root?
You should root your android phone and then you can use su command in adb.
There is some useful information in this link www.androidcentral.com/root
I use a Samsung Dart - SGH-T499 with Android v2.2.2 on it.
Now I need to edit the /system/etc/bluetooth/audio.config file. For that I rooted my phone using the SuperOneClickv2.3.3-ShortFuse. And browsed the file-system using Root Explorer. But I am unable to edit the permission of the audio.config. Could you please help me?
You also need to ensure that the /system directory, as it's a filesystem, is mounted read-write. In the adb shell use -o rw,remount as parameters to the mount command to do this. First you need to determine what ( hardware / physical / logical ) device that particular filesystem is stored on - use the mount command on its own to see the list and select the one which has /system as its mount point.
Can you not issue a
chmod 777 /system/etc/bluetooth/audio.config
...from the adb shell?