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:


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.


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:

Suggested articles

26 Comment(s)

Add comment


By: X

mpt-detect instead of mtp-detect

By: 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 :).

By: 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]:~$

By: 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.

By: proturk

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

By: 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.

By: Kamil

Problem started with android 6 hiding usb protocol options...

By: 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? 

By: aa

that is plank. he is using elementary OS

By: 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

By: 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

Error 1: Get Storage information failed.

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

LIBMTP_Get_Storage() failed:-1


By: 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.

By: Tcll

Heres the problem with libmtp when connecting your phone through usb:1: upon connecting the device, you may be unable to mount it: this can be worked around by unplugging the device and waiting at least 5 seconds before reconnecting it.5 seconds may fail though, leaving you stuck at the error again, even with 7 seconds...I've found waiting at least 10 seconds guarantees me a successful reconnection.2: once successfully mounted, when performing actions after some time has passed with no activity (perhaps you're writing a comment on a blog post), you may get errors like these:- F5: (after a download because it doesn't auto-update) cut/paste:

sorry for text-links, had to write this post in QuickEdit because it doesn't refresh the page after copying the shared link in G-photos. (PC has no net and I can't teather)

By: tlopez51

Got it working on Debian Jessie and a Samsung On5. Thanks for sharing.

By: John

I need help it says:

PTP_ERROR_IO: failed to open session, trying again after resetting USB interfaceLIBMTP libusb: Attempt to reset deviceLIBMTP PANIC: failed to open session on second attemptUnable to open raw device 0OK.

How do i fix this?

By: Deke

I've been trying to connect an old Lenovo A2109f tablet that's stuck in a loop although, I can boot it into recovery mode. Windows won't look at it even with ADB universal drivers (seems to be a common problem with Lenovo not giving out tablet drivers). So my problem is trying to get Linux to connect with it. It sees the tablet briefly when it goes through its' loop and then shuts down again. How do I get Linux to connect with it in recovery mode? This should be possible, yes?

By: dj--alex

NO WORK . Cannot install . Only mtp-tools  and it not enough

I dont want send every one file by console command. !

Xiaomi redmi 5


[email protected]:~$ sudo apt-get install mtpfs?????? ??????? ???????… ???????????????? ?????? ????????????       ?????? ?????????? ? ?????????… ??????E: ?????????? ????? ????? [email protected]:~$ sudo mtpfs -o allow_other ~/mntsudo: mtpfs: ??????? ?? ???????


By: Grünbär

Paket libmtp kann nicht gefunden werden.  so what?

By: Grünbär

No raw devices found. and now?

By: V Green

geezaloweeza are you kidding me? all of that to connect my phone to my computer for a transfer?  What a techie wet dream that is.

By: Brad

That is SO true--and well said.

By: CA2020

Hi, unfortunately I get the following error message,

[email protected]:~$ mtp-connectlibmtp version: 1.1.17Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).error returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize deviceNo [email protected]:~$ mtp-foldersAttempting to connect device(s)Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).mtp-folders: Successfully connectederror returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize deviceUnable to open raw device 0OK.

please if anyone in the community can help me out thanks


By: Roger Franz

Doesn't work. Linux doesn't see my Samsung phone. It did at one time, however. But now it does not.

By: R

Where would I find the commands to root/unlock bootloader & re-flash ROM? (using Mint--mate)

By: nmrk.n


Problèmes :

$ mtp-detect libmtp version: 1.1.18 Listing raw device(s) Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus.   Found 1 device(s):   Huawei: P9 Plus (12d1:107e) @ bus 3, dev 93 Attempting to connect device(s) libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device Unable to open raw device 0 OK.

$ mtp-connect libmtp version: 1.1.18 Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus. libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device No devices.

$ mtp-folders Attempting to connect device(s) Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus. mtp-folders: Successfully connected libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device Unable to open raw device 0 OK. $ mtp-files libmtp version: 1.1.18 Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus. mtp-files: Successfully connected libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device Unable to open raw device 0 OK. $

Que faire? merci.

By: Timely

It would really help if you would date your tutorial. As other have pointed out, Android connectivity worked great with 4.4 but sucks with 11. No one knows how old your tutorial is, so we don't even know what you're talking about.