30

I plugged my Kit-kat android phone up to my Ubuntu 14.04 computer and I enter the terminal and I want to be able to access files on my phone like the media and music folders through the terminal... is this possible?

cmehmen
  • 979

2 Answers2

31

Android devices usually uses the Media Transfer Protocol (MTP) when connecting via the USB. This protocol works differently than the traditional USB.

Simply put, this is a way to ensure that the phone does not share too much data with the computer. The computer makes a query, and the phone answers it. The phone may decide to share the file or ignore the query. Similarly, when the computer deletes a file, the phone has the ability to decide whether to actually delete the file or not.

Okay, enough introduction. To access a device connected via MTP, you need the information about it's #Bus and #Dev. To do so, you can run the following command.

usb-devices

This will provide you with a list of connected usb-devices. You need to find your device from this list. It can be a bit tiring, so you can search for the device with the available Manufacturer option. Simply use the following command.

usb-devices  | grep "Manufacturer=OnePlus" -B 3

This will provide you with 4 lines of information, where the firs line is as follows.

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 13 Spd=480 MxCh= 0

As you can see here, the associated Bus is 02, and Dev is 13.

Now change your directory to /run/user/1000/gvfs/ and see the list of folders there.

/run/user/1000/gvfs/
ls

You will find the associated MTP device with the #Bus and #Dev in the list. For example, mine was mtp:host=%5Busb%3A002%2C013%5D. Now simply change your directory using the following command.

cd mtp\:host\=%5Busb%3A002%2C013%5D/

Voila! You are inside the file storage!

20

You can find the mount point under the $XDG_RUNTIME_DIR/gvfs directory. The main directory may be something like mtp:host=… with some escaped characters and USB vendor/product IDs, but you should be able to access your files from in there in a terminal.

dobey
  • 41,650