Use adb to transfer files between your computer and mobile phone, and use the adb mobile phone to transfer files

Source: Internet
Author: User
Tags superuser permission

Use adb to transfer files between your computer and mobile phone, and use the adb mobile phone to transfer files

First, you need the root mobile phone.


Then, "Win + R" opens the cmd window. The following example describes how to copy d: \ 1.txt to the/system/directory.

Adb push source (localpath) dest (mobilepath)

D: \> adb push 1.txt/system
Failed to copy '1.txt 'to'/system/1.txt ': Read-only file system


Mount the/system partition first

Adb devices

D: \> adb devices
List of devices attached
4d00a813e1e84041 device

If there are no devices in this list, check the phone connection.


Adb shell Remote login to the linux System of the mobile phone

D: \> adb shell
Shell @ android:/$

The su command gets the superuser permission, and the command prompt changes from "$" "#"

Shell @ android:/$ su
Shell @ android :/#


Df command to view disk space usage of the file system

Shell @ android:/# df
Filesystem Size Used Free Blksize
/Dev 930 M 80.0 K 930 M 4096
/Mnt/secure 930 M 0.00 K 930 M 4096
/Mnt/asec 930 M 0.00 K 930 M 4096
/Mnt/obb 930 M 0.00 K 930 M 4096
/Persdata/absolute 11.8 M 4.09 M 7.68 M 4096
/System 2.69G 2.27G 434 M 4096
/Efs 19.6 M 9.15 M 10.5 M 4096
/Cache 1.99G 32.4 M 1.96G 4096
/Data 8.92G 7.66G 1.26G 4096
/Mnt/shell/emulated 8.90G 7.66G 1.24G 4096
/Mnt/shell/container 8.90G 7.66G 1.24G 4096

/The system partition is 2.69 GB.


Next, view the partitions under/proc.

Shell @ android: // # cat/proc/partitions
Major minor # blocks name
253, 0, 409600, zram0
179 0 15388672 mmcblk0
179 1 4096 mmcblk0p1
179 2 4096 mmcblk0p2
179 3 20480 mmcblk0p3
179 4 4096 mmcblk0p4
179 5 4096 mmcblk0p5
179 6 4096 mmcblk0p6
179 7 20480 mmcblk0p7
259 0 8192 mmcblk0p8
259 1 8192 mmcblk0p9
259 2 8192 mmcblk0p10
259 3 8192 mmcblk0p11
259 4 8192 mmcblk0p12
259 5 90112 mmcblk0p13
259 6 262144 mmcblk0p14
259 7 4096 mmcblk0p15
259 8 573440 mmcblk0p16
259 9 12288 mmcblk0p17
259, 10, 4096, mmcblk0p18
259 11 2121728 mmcblk0p19
259 12 2830336 mmcblk0p20
259 13 9379840 mmcblk0p21.

Mount mmcblk0p20 based on size

Shell @ android: // # mount-o rw, remount/dev/block/mmcblk0p20/system

I tried it without partitions. It is also possible.

Shell @ android:/# mount-o rw, remount/system

After use, you can change to read-only.

Shell @ android: // # mount-o ro, remount/dev/block/mmcblk0p20/system


Execute copy

D: \> adb push 1.txt/system
Failed to copy '1.txt 'to'/system/1.txt ': Permission denied

Run the ls-l command to view the file permissions. You can see that the shell user does not have the read/write permissions and modifies the file permissions.

Shell @ android: // # chmod 777/system

Push again.


Similar to copying files from a mobile phone to a computer, adb pull source (mobilepath) dest (localpath)

D: \> adb pull/system/1.txt D: \ game

If the message "Permission denied" is displayed, You need to modify the File Permission. the chmod xxx file name. To modify the attributes of all files in the directory, use chmod xxx *.*.


How adb transfers files

Adb push original file address destination file address
The original file address is relative to the computer, and the destination file address is relative to the mobile phone

It is still easy to manage files in the computer client of QQ Mobile Phone Manager.

What command can ADB use to copy files in the mobile phone database to a computer and an external memory card?

Use the adb pull command.
For example, copy contacts2.db to a local machine.
Adb pull/data/com. android. providers. contacts/databases/contacts2.db
Run the command in the command line instead of running the command after the adb shell enters.
After the command is executed, the file is pulled to the local location of the current command line.

To copy data to an external memory card, run the command in the adb shell. android is based on linux, and the copy command is not copy, but cp, which is similar to the copy command in windows.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.