Transferring files between PC and Android is easy. But while working on a project which requires sending files back and forth between your computer and mobile device you may find this ADB commands useful. Whether it’s a certificate file or an image it’s easy to transfer files with ADB. I believe I do not have to state that this requires connecting your device via USB and having the required drivers installed on your computer.
First, you should make sure you have ADB installed on your computer. On Debian based systems you can get it from the apt repos with this command.
[email protected]cagdas-mint:~$ sudo apt-get install adb
If you have Android SDK laying around somewhere it is also included in it. You can find it and run a terminal from there.
After installing adb successfully you should be able to list devices and see if your device is detected or not. By running
adb devices command. If you can see your device below which means you can access and use most of the features included in adb.
[email protected]:~$ adb devices List of devices attached LGH8********* device
After this point you can send files with
adb push [LOCALPATH] [DESTINATIONPATH] command. If you don’t know the structure of your mobile device you can always call
adb shell to get a terminal from the android device. Than you can view all directories and files.
[email protected]:~$ adb push /home/cagdas/Desktop/owasp_zap_root_ca.cer /mnt/sdcard/adbFiles /home/cagdas/Desktop/owasp_zap_root_ca.cer: 1 file pushed. 0.0 MB/s (1809 bytes in 0.041s)
Pulling files is easy too. Instead of push we will be using pull command. First parameter is the remote file’s path and the second is the local path.
[email protected]:~$ adb pull /mnt/sdcard/adbFiles/owasp_zap_root_ca.cer /home/cagdas/Documents/cert.cer /mnt/sdcard/adbFiles/owasp_zap_root_ca.cer: 1 file pulled. 0.2 MB/s (1809 bytes in 0.010s)
And that’s how you transfer files with adb. I believe it is quite easy and straightforward. Sometimes saves a lot of time I always find it difficult to send files over a directory browser. If you are already connected adb is the way to go.
You can learn more about android debug bridge from here.