Page 1 of 2

Transfer Files between Android and Debian

Posted: 2022-12-07 22:38
by pwzhangzz
For a long while I have been using the mtp protocol to transfer files between my android phones and my (Linux) desktop via a usb cable. Recently I realized that the file dates were not copied. After a brief search, found the following simple solution:

1. Install go-mtpfs from Debian repo;
2. Create a folder in the $HOME directory to store data to be transferred from android (in my case, MotoG);
3. Reboot (may not be necessary);
4. Open a terminal and execute the "go-mtpfs MotoG" command;
5. Open another terminal, go to the MotoG directory then run a "rsync -a" command with other appropriate parameters and arguments.


When done, make sure to umount the mtp drive:

fusermount -u MotoG

Thanks to the following excellent write-up:

https://askubuntu.com/questions/1339126 ... 93#1346893

Re: Transfer Files between Android and Debian

Posted: 2022-12-07 23:17
by CwF
Why so complicated!

My GoFlip something appears as an icon on the desktop that actually looks like the phone!
Click it, it opens in Thunar. works fine. Often, I soft pass it to vm's, some not local. Works fine.
The usb device selection in virt-manager calls it an 'android android', and it's not even android. I should change that...

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 00:57
by pwzhangzz
Nautilus will do this without any additional effort. The problem was that sometimes dates (probably other file attributes too for example thumbnails) were not copied. The go-mtpfs app allows android system to be mounted on the pc thus allowing rsync operations via a usb cable. A 10+ GB folder takes less than 1 min. Plus I can use Nautilus' space and up-down cursor keys to preview the photo/pdf files. Pretty Neat.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 02:09
by sunrat
In KDE Plasma, Dolphin can mount phones and transfer easily. I usually use kdeconnect via wifi as it saves plugging in a cable. :lol: Sent files from phone appear in Downloads directory by default. kdeconnect is not limited to KDE despite its name.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 03:51
by pwzhangzz
Since I'm a big gnome fan (not the the gnome desktop itself which really sux but the gnome 4.3 extensions are what got me hooked), I have also previously used GSConnect (gnome version of KDEconnect) to do file transfers. I don't think I can cd to the mount point and run shell operations? ? ?

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 08:25
by peer
on my pc: filezilla
on my android: ssh server
transfer over wifi with ssh.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 08:36
by canci
KDE Connect (which would be installed as a dependency anyway if you install GSConnect) does have a CLI interface called kdeconnect-cli.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 09:20
by pwzhangzz
Me bad. The title should have been not just about file transfer but also about mount point. Understandably there must be at least a million ways to do the file transfer between a pc and an android.

Actually, most people find a need to clean their cell phone storage (which usually contains tens of gigabytes of photo images) only when (1) they change to a new phone or (2) their (free) Google cloud storage allocation is about to become full. Being able to cd to the directory in which the Android file system is mounted on the pc not only allows us to use appropriate Linux tool to do fast and complete file transfers, it also allows us to run bash/python etc operations on such a huge glob of data and impress the sh*t out of everyone watching. Linux rules! Debian rules!

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 09:33
by Hallvor
sunrat wrote: 2022-12-08 02:09 In KDE Plasma, Dolphin can mount phones and transfer easily. I usually use kdeconnect via wifi as it saves plugging in a cable. :lol: Sent files from phone appear in Downloads directory by default. kdeconnect is not limited to KDE despite its name.
Indeed. kdeconnect is pure awesomeness. Transfer files wirelessly, Answer SMS messages on the computer, and if someone calls you the music or video on the computer stops automatically, and then resumes the moment you hang up. It can even help me find my phone when I have misplaced it at home.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 11:26
by NFT5
Hallvor wrote: 2022-12-08 09:33 kdeconnect is pure awesomeness
Agree, and you can specify which folder the transferred files are copied to.

Re: Transfer Files between Android and Debian

Posted: 2022-12-08 14:03
by CwF
pwzhangzz wrote: 2022-12-08 09:20 Me bad. The title should have been not just about file transfer but also about mount point. Understandably there must be at least a million ways to do the file transfer between a pc and an android.
...snip... Linux rules! Debian rules!
No doubt!

So many ways! My flipper battery last for days and is data restricted so I use the cable to charge it, and load podcast and the like for the next week while tethered.

A while back I wanted to have limited tooled vm's (no sudo, no polkit) recognize a usb by name and mount it automatically using pmount. I forgot the outcome...

Re: Transfer Files between Android and Debian

Posted: 2022-12-09 15:28
by oswaldkelso
peer wrote: 2022-12-08 08:25 on my pc: filezilla
on my android: ssh server
transfer over wifi with ssh.
This though I use https://ppareit.github.io/swiftp/ and midnight commander or gftp

Super simple to use and very reliable. Conversely I always found MTP to be very unreliable unnecessary.

Re: Transfer Files between Android and Debian

Posted: 2022-12-09 17:20
by pwzhangzz
Currently the mtp driver in sid has been upgraded to version 1.1.20. Look forward to Bookworm to acquire the stable status. Good point, although I think it is already pretty reliable in Bullseye.

Debian's go-mtpfs package allows us to "bootstrap" an android or iOS file system to the Linux kernel (i.e., "mounting") without installing any apps on the cell phone (mtp is already built in). But being able to go inside the mount point and run bash etc operations also allows us to showcase our computer prowess. Unlike most other Windows/Apple "experts". :D

Re: Transfer Files between Android and Debian

Posted: 2022-12-09 21:08
by FreewheelinFrank
Total Commander Send Via Wifi.

Files go in seconds.

Re: Transfer Files between Android and Debian

Posted: 2022-12-10 10:51
by oswaldkelso
FreewheelinFrank wrote: 2022-12-09 21:08 Total Commander Send Via Wifi.

Files go in seconds.
Did you mean double commander ?

Re: Transfer Files between Android and Debian

Posted: 2022-12-10 11:25
by FreewheelinFrank
oswaldkelso wrote: 2022-12-10 10:51
FreewheelinFrank wrote: 2022-12-09 21:08 Total Commander Send Via Wifi.

Files go in seconds.
Did you mean double commander ?
No, definitely Total Commander. It has plugins for WiFi, Lan, Drive, OneDrive, WebDav... Free, no ads. It's the kipper's knickers

Re: Transfer Files between Android and Debian

Posted: 2022-12-10 12:52
by ComputerBob
Does Total Commander need to run in Wine?

Re: Transfer Files between Android and Debian

Posted: 2022-12-10 21:48
by FreewheelinFrank
ComputerBob wrote: 2022-12-10 12:52 Does Total Commander need to run in Wine?
Total Commander is Android side. Send via wifi gives you a link to enter into a browser. There are download links for the files you want to share. TC must set up an http server. That's what I do if I want to copy several photos to the computer because it takes seconds where Bluetooth takes minutes.

I've never done computer to Android, and I couldn't find any Linux apps that do share by wifi, but setting up a temporary http server and entering the address in the wifi plugin in TC makes all files visible in TC to view, play or download.

Code: Select all

$ cd Downloads
~/Downloads$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Then enter x.x.x.x:8000 (computer IP address) into TC.

TC has a QR code reader to make setup even easier. I'm sure it would be possible to write a script to start an http server and flash up a QR code.

https://www.linux-magazine.com/Online/F ... s-in-Linux

Re: Transfer Files between Android and Debian

Posted: 2022-12-10 22:48
by FreewheelinFrank
Here is a script to use with Total Commander Receive via Wifi plugin.

Install qrencode and imagemagick packages.

Change IP address for that of your computer, save script as share.sh (or any other name) in home directory and make executable.

Make sure port 8000 is open (I'm assuming this is a local network behind a firewall).

Code: Select all

#!/bin/bash
python3 -m http.server &
qrencode -o qrcode.png 'http://192.168.2.16:8000/' &
display qrcode.png
Run

Code: Select all

$ ./share.sh
from user directory and scan the QR code that pops up with TC. Contents of home directory will then appear in TC to view, play or download. You can even navigate to sub directories.

Edit: here's a version that will find the IP address automatically:

Code: Select all

#!/bin/bash
ip=$(hostname -I)
echo http://${ip/ /}:8000/ > url.txt
python3 -m http.server &
qrencode -s 8 -r url.txt -o qrcode.png &
display qrcode.png
Edit 2: made the QR popup a sensible size with "-s 8" (width of code blocks in pixels).

Re: Transfer Files between Android and Debian

Posted: 2022-12-11 00:33
by sunrat
KDEconnect context menu - send from desktop to phone (Realme 7 Pro):
sendtophone.png