Using Android developement bridge in Linux

Hi all, just a quick lowdown on how to utilize the adb tool in Linux. Enjoy!

Of course, the first step is to install adb.

# aptitude update

# aptitude search android |grep adb
i android-tools-adb – Android Debug Bridge CLI tool

# aptitude install android-tools-adb

You now also need to set “developer mode” or “USB debugging” on your phone or tablet in the settings.

The second step in using adb is to detect any connected devices, by using the devices modifier:

# adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
04039C4E19009019 device

Great news! It found the device. If it does not find the device, it will simply have nothing after “List of devices attached”, like this:

# adb devices
List of devices attached

If this happens, you may have had a problem like me, where I needed to add a udev rule. See my article “RWE: Udev rules for cell phones” if this happens to you.

Using adb to install an apk file (Android program):

# ls
6_worms_2_armageddon.apk org.dyndns.sven_ola.debian_kit.apk
com.alonsoruibal.chessdroid.lite.apk

Here we see a list of two games and Sven’s Debian kit. Now let’s install it with the adb install command. Note: I am using a -s modifier to install the program to the sdcard, otherwise it will go to internal storage.

# adb install -s org.dyndns.sven_ola.debian_kit.apk
1079 KB/s (505832 bytes in 0.457s)
pkg: /sdcard/tmp/org.dyndns.sven_ola.debian_kit.apk

Then we get our Linux images to put on our phone:

# ls
backupdeb.img debian.img ext3 ubuntu.img.md5
bakdebext3.img debian.img.md5 kalilinux.ext2.img ubuntu.sh
debext3.img debian.sh kalilinux.ext2.img.md5
debianext3.sh ext2 ubuntu.img

As you can see, I have several Linux images for my cell phones. Now we should put one on the phone with the adb push command. Here I have put the file onto the sdcard of the device.

# adb push ./bakdebext3.img /sdcard/
2028 KB/s (2146435072 bytes in 1033.403s)

You can also pull a file off of your phone:
# adb pull /sdcard/installed/scripts/dk.jpeg ./
3196 KB/s (3899182 bytes in 1.191s)

Finally, we can enter the phone in a shell mode with the (you guessed it) adb shell command:

# adb shell
$ cd /sdcard
$ mkdir installed
$ cd installed
$ mkdir scripts
$ exit

Using these commands you can get, put, or install just about anything to or on your phone or tablets. It is a great tool in the process of rooting your Android devices.

Linux – keep it simple.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s