Connect your Android device on Ubuntu Linux

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

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.

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.

Source: howtoforge.com