How to connect your Android device on Ubuntu Linux

Buying a media device that needs a special driver and/or connectivity suite to navigate and update its contents is a common case nowadays, and has been ever since manufacturers decided that it would be a good idea to just limit the access that users can have on the products that they bought. This may not be a huge problem to Windows and Mac OS users who can simply download the manufacturer's suite and use it to connect to their device, but Linux is often (if not always) left unsupported in that part. The first time I encountered this problem was with the first generation of iPods and Creative Zen players that refused to show any contents on the File Manager when connected via the USB port, and then came the newest generations of Android devices which do the same. In this quick guide, we will see how we can overcome this problem, and connect our media device on our Linux system.

MTP - Basic File Transfer Options

First thing we need to do is to install “libmtp” which enables us to use an additional media transfer protocol for the USB ports. If you're using Ubuntu, you can do this by opening a terminal and typing:

sudo apt-get install libmtp

After this is done, you may connect your media device on the USB, and then type:

mtp-detect

On the terminal.

Installation of libmpt on Ubuntu.

This command will yield some basic information for the connected device. You may have to wait for a few moments for everything to be displayed and the command to finish running. If your device can't be detected, then you may have to find a newer version of libmtp in the hope that support for your device has been added.

Then insert the command “mtp-connect” followed by “mtp-folders” to see the contained folders and their IDs.

mtp-connect
mtp-folders

Note that you should not attempt to open the device from your file manager in the meantime, as this will interfere and make it “busy” so the “mtp-connect” command won't work.

The mtp-connect and mtp-folders commands.

Using the “mtp-files” command will display all files in your device, their IDs, their parent folders IDs, and their file sizes. Now if you want to copy a file from the media device to your computer, you simply use the “mtp-getfile” command followed by the file's ID and the filename that you want to be used for the newly created file. The exact opposite which is sending a file from your computer to your USB device can be done by using the “mtp-sendfile” command.

Here's an example where I want to send a file named fg.ods and I want it to be copied without a change in it's title.

Send a file with mtp-sendfile.

MTP – Mount Options and GUI Navigation

Working through the terminal can be cumbersome, especially when your media device contains a large number of files. If you give the “mtp-detect” command a go and you see that it is working with your device, then you have the option to mount it and navigate in its storage more conveniently through your file manager.

For this, we have to install mtpfs by giving “sudo apt-get install mtpfs” on a terminal, and then “sudo mtpfs -o allow_other ~/mnt”.

sudo apt-get install mtpfs
sudo mtpfs -o allow_other ~/mnt

This action should create a new mountpoint on /mnt which you can also access via the terminal if you prefer to. If this doesn't work, you can give Qlix a try which is a minimalistic GUI MTP devices manager.

How to use mtpfs.

mtpfs - part 2.

As we're dealing with Android devices on this tutorial, we should keep in mind that those are not just phones but also mp3 players and cameras. This means that you can access them in a smarter way as well, like through the Clementine music player for example. Open Clementine, go to “Devices” and double click on the Android icon. This should mount your device and display the contained audio files that should be perfectly accessible and playable.

Open Clementine and navigate to android icon.

If you right-click on the icon of the device and choose the “Properties” option, you will get information such as the device's mount point, formats supported, and the USB radio interface. The mount point in particular, can be used to access the storage of the device with your file manager.

open properties of the android device.

Share this page:

11 Comment(s)

Add comment

Comments

From: X

mpt-detect instead of mtp-detect

From: Y

From my experience mtpfs is not fully stable in Linux and mtp per se is not worth any trouble. The best way to access files on an android device from Linux is to install a ssh server app on the device (e.g., SSHelper) and use a ssh client of choice from Linux to access it - it is safe, most gui file managers in Linux can be used as ssh clients, it works over WLAN too no need to phycally connect the device via cable. Whether you trust an android device to be in same WLAN as your Linux box is another topic :).

From: cmcanulty

error on first step

 

[email protected]:~$ sudo apt-get install libmtp[sudo] password for cmcanulty: Reading package lists... DoneBuilding dependency tree       Reading state information... DoneE: Unable to locate package [email protected]:~$

From: woo

i gave up on mtp lib a long time ago. It was unusable in ubuntu 12.04 and debian wheezy... instead I use samba shares and the ES File Explorer app on android.

From: proturk

you should give a try to gMTP. its gtk based and will work faster on gnome, xfce, unity.

From: Don Morse

ummmm, what's wrong with simply connecting with a USB cable, making sure the android screen is unlocked.  file manager opens and I've got full access to my Samsung Galaxy 5 as though it was an external drive.  I can play movies from it or even listen to music.  It's also how I back up the device, to my 1Tb external USB drive.  I've been doing this with almost every version of Linux Mint or Ubuntu for several years.

From: Nagy Csaba

Hello!Thanks for the tutorial. I have two question. What is the name of the dock? And how can I do transparnecy the upper tray? 

From: aa

that is plank. he is using elementary OS

From: Michael Ray

ok i have a question im in the process of building a printer and a file server using linux say i need to print from the server how do i get the tablet to communicate with the server

From: Bill Wilken

Thanks for your info, but it doesn't work on 64-bit Ubuntu 16.04.  While it can find the phone, it cannot find any storage information:  See below --

Listing raw device(s)

Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).

   Found 1 device(s):

   Samsung: Galaxy models (MTP) (04e8:6860) @ bus 1, dev 9

Attempting to connect device

LIBMTP ERROR: couldnt parse extension samsung.com/devicestatus:4

Error 1: Get Storage information failed.

Listing File Information on Device with name: SAMSUNG-SM-G920V

LIBMTP_Get_Storage() failed:-1

 

From: Z

I think Y is right. The best way to connect an android device to Ubuntu or whatever other linux distro, is to install a ssh server app and access to it through local ip address using a file manager as a ssh client.