Tuesday, November 5, 2013

Connect Android and Linux using USB

I have a Samsung Galaxy Tab 2 tablet, running Android 4.1.1 (aka Jelly Bean). I'd like to transfer some files from the tablet to my Linux server running Debian 7.2 (aka Wheezy). The Android tablet connects via Wi-Fi to the same LAN as the Linux server.

There are many ways to transfer files between the 2 devices. For example, you could install an Android app named AirDroid which lets you manage your Android device from a desktop web browser, including file transfer. In this post, I'll go another route, an arguably more direct and basic one. I'll connect the 2 using a USB cable.

  1. Connect the 2 devices using a USB cable.
  2. With the Android device, navigate to the home page.
  3. Swipe down from the top of the page.

    You will see a message "Connected as a media device. Touch for other USB options"

  4. Tap on the message.

    The resulting screen specifies how you want the Android device to connect: as a Media device(MTP) or a Camera (PTP).

    While Linux has some support for MTP, I found it much easier to connect as PTP.

  5. Tap on the Camera (PTP) checkbox.
  6. Swipe down from home page again, and you will see that the tablet is mounted as a camera.
  7. Reset the USB device under Linux.

    The simplest way is to unplug the USB cable from both ends, and plug it back in.

  8. Make sure that the Android device is mounted on your Linux server.

    On my Linux GNOME 3 desktop, I clicked on the Computer icon, and the Android device was detected (GT-P3113). Click the device to mount it.

  9. Run your favourite file manager application on Linux, and proceed to transfer files.

You can use the above method to transfer files if you happen to have (the right) USB cable around to connect the 2 devices. If cables is not your preference, you may want to look into the Android app Airdroid.

13 comments:

Anonymous said...

Simple and fast. love it, thank you, Aah

Eric Klopper said...

Just saw your post now. Perfectly done. Between your solution and Airdroid I have everything I need for my Galaxy Note 3 / Debian integration.

Thanks from South Africa, Eric

Anonymous said...

Good job ! ...

Anonymous said...

Doesn't work for .mp3 files. Might be the cable...

Anonymous said...

Connecting as a camera will only transfer image files... all other types are not visible.

sarah said...

Thanks for this blog very usefull information

Unknown said...

We can only transfer Image files. How to transfer videos and other files? Please help..

ben said...

Have you also been able to view video from the android camera via usb?

I've found some projects. but no luck

https://github.com/bluezio/ipwebcam-gst
https://github.com/hyongbai/AndroidUsbCamera
https://github.com/yangh/uvcvideo

Unknown said...

All i have on the android phone is a charge flash

crocodile_dondii said...

This means your phone is set to the "USB for charging the phone" instead of PTP. You can get at this in settings/bt and device connection/usb.
The usb may not show until it's actually connected by the cable.

Incidentally the cable must be a "charging and data transfer" type of cable. The newer ones ARE, but if you have an older phone, you're going to need to find a cable that support data transfer...assuming your phone can do this, of course...

If you've had it connected to a Windows computer before, it will transfer data.

Skitnevsky said...

I just done this from start to finish. Worked a charm. Thank you.

floogy said...

MTP and mounting gives you access to all file types.

Unknown said...

Dear sir
When i press daim@tomy.../Desktop$ls
Daim.jpg(my picture) rony (dir).For copy my pic. to my mobile by usb cable. I press daim...$ cp Daim.jpg /run/user/1000/gvfs/mtp...../phone/picture but result is permisson denied ! what is solusion?mobile to desktop copy & move posible but not from desktop to mobile.