Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Neil Bothwick claims he was born and raised on a server farm.
Q Cordless phone
I need an easy way to transfer files between my Linux PC and my Android phone, a Samsung S21 Ultra. These are mainly music and image files. I have tried a few different ways (particularly via USB cable) and had some limited success. However, although USB cable should be the easiest, I’m finding it awkward and prone to not mount the handset or drop out after a short amount of time.
Is there an easy way to transfer files wirelessly on the same network? If so, what are the best options or apps?
Abigail Nolan
A Android phones use MTP (Media Transfer Protocol) for transferring data over USB. There’s a number of MTP filesystems for Linux, such as jmtpfs, that can mount an MTP device for file copying, but none seems startlingly reliable.
The simplest way to transfer smaller files is to copy them to your Google Drive account, which you have if you use Android, then you can access them on your computer and your phone. Native Drive support in Linux is poor, but you can use a web browser to transfer files. It’s how this text arrived at LXF Towers.
Another option is AirDroid, available from the Play Store. It allows a lot more than file transfers but, once again, Linux users are restricted to the web client. AirDroid is a paid program, with the free version restricted to 200MB per month, making it only suitable for very light or heavy users.
If you want unrestricted copying, you can mount your phone over the network using SSHFS. First you need to install SSH Helper from the Play Store and set a password. You may also need to install SSHFS on your computer. Now you can mount your phone’s storage by making a note of the IP address shown in SSH Helper and running the following command in a terminal on your computer, using the IP address you just noted:
$ sshfs IP-ADDRESS:/storage/emulated/0 ~/Android -p 2222
The mount point, ~/Android here, must exist and be empty.
Another suitable alternative is Syncthing, available for Android and Linux (and just about everything else). This program provides automatic synchronisation between shared folders on devices, so it is simply a matter of copying a file to the shared folder, then it automatically appears on the other device(s). Syncthing is configured through a web interface, but this the intended way, not a poor man’s alternative. Once set up, the range of options is large, with any combination of multiple shared directories on multiple machines being possible.