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?

  • Depends on the vendor. Some (Samsung) make it harder, others easier. – mikewhatever Mar 13 '15 at 19:21
  • I have the note 4 @mikewhatever – cmehmen Mar 13 '15 at 19:25
  • 2
    ...and what happens when you connect it? Does Ubuntu see it? What's the output of dmesg? Is there an option is the phone settings to allow connecting to USB? – mikewhatever Mar 13 '15 at 20:15

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.

| improve this answer | |
  • I'm uncertain how to follow your instructions. What directory is $XDG_RUNTIME_DIR/gvfs in? I can't find it anywhere. Is it hidden? – Sarah Szabo Jan 30 '18 at 0:51
  • 1
    The $XDG_RUNTIME_DIR defaults to /run/user/$UID/ I think. There is a gvfs sub-directory within it. – dobey Jan 30 '18 at 3:02
  • I've found the gvfs directory, but I don't see anything in it using the ls` command. – Sarah Szabo Jan 30 '18 at 21:40
  • OK. This was working when I answered the question in 2015 on 14.04. Maybe something changed/broke in newer Ubuntu in relation to this? – dobey Jan 30 '18 at 23:05
  • Possibly, should I re-ask the question, bu with it related to modern systems? – Sarah Szabo Jan 31 '18 at 2:20

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.


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.


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!

| improve this answer | |
  • 3
    Awesome! Worked like a charm, thx – Justin Oct 3 '18 at 5:30
  • 2
    Worked like a charm, but it wasn't mpt:host, it was gphoto2:host – user1271772 Oct 13 '18 at 0:24
  • 3
    What if there is nothing in /run/user/1000/gvfs/. My ls doesn't show anything. – Nikhil Wagh Oct 22 '18 at 10:17
  • same here. the folder is empty. i set my phone to 'file transfer' mode in case that matters. – roy May 16 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.