Kubuntu: How to access your phone via the commandline

When I connected my phone to my Kubuntu laptop using a USB cable I experienced an astonishing phenomenon: Opening up a Dolphin (file manager) window I could easily navigate to it, browse the whole directory contents, but when I tried to get there via commandline I had no chance at all! Same for Double Commander, of course.

Dolphin presents the phone as a device mounted by means of

mtp

(Media Transfer Protocol). I started to install jmtpfs, just as one example. But launching jmtpfs it threw this error:

Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus. 
error returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize device 
terminate called after throwing an instance of 'MtpErrorCantOpenDevice' 
 what():  Can't open device 
Aborted (core dumped)

The solution to the problem is listed in this error message but I was to dumb to recognize it, at least for some time. The reason is:

DO NOT AUTOMATICALLY MOUNT ALL AND EVERYTHING!

If you do (and so did I) KDE mounts the phone asap after connection, and Dolphin can use this connection right away. But you will not be able to find even a trace of gvfs! And jmtpfs cannot access the bus (because it’s already claimed by another process) and therefore gives an error message! I tried to find the mountpoint all over the place, to no avail. Even lsusb did not help and showed nothing which I could identify as the connection to my phone.

Then I installed the following software using apt-get install:

gvfs-bin
gvfs-backends
gvfs-fuse
gvfs-daemons
gigolo

Gigolo is a graphical backend which is fine for trouble-shooting.

After I had installed these packages, I eventually found the crucial gvfs directory in

/run/user/<youruid>/gvfs

To get to know your UID enter

id -u <username>

or

echo $UID

You can install a symbolic link like

/mnt/gvfs

and access the directory from there which works also fine with Double Commander! Do not try to create symbolic links deeper than gvfs, this won’t work!

After I had installed the abovementioned packages, lsusb showed my phone with bus and device ID. Now I can navigate through the phone’s directory structure by console commands, Double Commander, and everything else which is appropriate.

PS: Important!

After this article had been published I found out that the problem occurred again. But I could resolve it (hopefully forever now) by taking my user account out of the plugdev group. I simply had to logout and login, then I could do with the device whatever I wanted.

PPS:

I would have liked more to find out all the details about the processes which are invoked under KDE in order to taylor the configuration to my needs. But this was too complex and would have afforded serious amounts of work and investigation. That’s exactly something I don’t like at all with KDE. It looks nice, it has a very comfortable user interface which gives easy access to many things you’ld probably like to control, but there are limits which are hard to overcome even by very experienced and knowledgable users who also do not back off on great amounts of work. But at the end of the day that’s a matter of taste.