A regular Ubuntu user might have faced this situation: connect an Android smartphone to the laptop over micro USB to find even the battery is not charging! Things look so simpler on Windows: the phone get charged, phone storage is accessible and what not? What’s wrong with Ubuntu??? Honestly, nothing! All of this is possible on Ubuntu as well. We will explore how in this article.

Note that we will use the adb (Android Debug Bridge) to communicate between an Android smartphone and an Ubuntu laptop. There are other ways to get Android notifications on Ubuntu, remote control, transfer files over protocols like ftp or connect to Ubuntu over ssh.

Goals

Get the phone detected on Ubuntu with charging Access phone storage in Ubuntu file browser Transfer files between phone and Ubuntu Take full backup of the phone and restore

Setup

Lenovo A6000 Plus (Android 5.0.2)

Ubuntu 14.04

Micro USB cable to connect phone and laptop

Procedure

Phone detection

If your phone is not auto-detected, the reason is you to not have MTP (Media Transfer Protocol) installed to communicate to the phone. To install it on Ubuntu, run:

$ sudo apt-get install mtpfs

Now disconnect and reconnect the phone using the micro USB cable. Charging should start. Tap on the Connected as a media device notification and set the connection mode to USB storage device. The phone internal storage and any microSD cards should show in your file browser (Nautilus, PCManFM etc.) now. On my model I had to press Open USB storage device option to show the additional microSD storage.



adb

To achieve the last 2 goals we will use adb. abd comes with the full Android SDK but you can also install the tools required for our purpose separately on Ubuntu:

$ sudo apt-get install android-tools-adb android-tools-fastboot

Enable USB debugging on your phone from the same notification or from Settings menu. This is a must to establish adb connection to the phone. On Android 4.2.2, you must approve the secure debugging feature manually.

You must run all adb commands as root or sudoer.

Start the abd server:

$ sudo adb start-server * daemon not running. starting it now on port 5037 * * daemon started successfully *

List connected devices:

$ sudo adb devices List of devices attached 4da100f2 device

At this point, your device should show in the list.

Login into the device:

$ sudo adb shell shell@Kraft-A6000:/ $

The shell you get now is running on your phone! You can check some of the available commands:

$ top $ vmstat

List all available commands:

$ ls /system/bin

Isn’t Linux amazing? 😉

Press Ctrl-d to get out of the device shell.

Transfer a file from your phone to laptop:

$ sudo adb pull /sdcard/DCIM/Camera/VIDEO.mp4 ~/

Copy a file from laptop to phone:

$ sudo adb push ~/IMAGE.jpg /sdcard/DCIM/Camera/

The syntax are:

adb push <local> <remote> adb pull <remote> [local]

Backup your phone:

$ adb backup -apk -shared -all -f backup.bak

Restore the backup:

$ adb restore backup.bak