2

So yeah it seems to me most people don't bother with USB anymore and just connect wirelessly using KDE Connect app but honestly I'd rather just do it wired, wired is the most secure way to do it in my opinion, I just want to plug my phone into the PC via USB and transfer files.

So what is the definitive way to plug my phone into my PC via USB and transfer files from phone to PC or vice versa?

I went and googled "how to connect android smartphone to computer through usb linux" and hardly any search results turned up, and the ones that did turn up are out of date (it seems to me the vast majority of Linux users just use KDE Connect app, it seems hardly anyone bothers with USB anymore) but I really don't want to transfer files wirelessly I'd much rather do this through a wire.

This turned up on Google search though, this article tells you how to transfer files via USB on Linux but how accurate is it? https://www.debugpoint.com/how-to-access-android-devices-internal-storage-and-sd-card-in-ubuntu-linux-mint-using-media-transfer-protocol-mtp/

I mean I thought it was going to be so easy, I thought I'd just plug my phone into my PC and transfer a few files, I didn't think it'd be this hard. So like I said, it seems to me basically everyone just uses KDE Connect, it seems hardly anyone even bothers with USB anymore. I don't know, should I just go with KDE? But is KDE 100% secure? Whereas I know a USB wire is totally secure. But it looks like transferring files via USB isn't going to be as easy as I thought it'd be on Linux.

Please I just need experts to tell me what to do here? What do i do?

I guess if I'm told "Hey don't bother with USB, just use KDE." Then I guess I'll consider doing that. I just thought it would be so easy to do this using USB but here I am about ready to pull my hair out, I'm very frustrated with this.

Btw I've got a Pixel 6a smartphone and it came with a USB adapter that plugs into the USB-C port on the phone, that way I can hook up a regular USB cable to the phone. I ordered a USB 3.0 data transfer cable off of Amazon.

user68186
  • 37,795
SpaceX
  • 145
  • Please read https://askubuntu.com/help/how-to-ask and https://askubuntu.com/help/formatting . Take the [tour]. – waltinator Oct 17 '23 at 22:04
  • 1
    "I thought I'd just plug my phone into my PC and transfer a few files, I didn't think it'd be this hard." ... have you actually tried doing just that? – muru Oct 18 '23 at 05:02
  • 1
    I simply plug my scamdroid into the computer with a USB cable, and on the phone a popup window asks Allow access to phone data? you accept and that's it. You can move/copy/delete as allowed by the phone. –  Oct 28 '23 at 14:48
  • The phone might also have a selection under the usb notification, power/data (Select mtp data). The Media Transfer Protocol (mtp) packages should already be on your pc. The usb connected phone should appear in the file navigator, drag and drop. – ubfan1 Nov 03 '23 at 04:21

4 Answers4

6
  • Copying files via USB from my android phone to the PC with Ubuntu is easy, connect the phone directly to the PC via USB. As already mentioned by yehtetmaungmaung, in the phone you must allow it (in a popup window).

    enter image description here

    I do this often in order to copy photos to the PC, and I use two windows of the file browser 'Files' alias nautilus for this purpose, one viewing the source directory in the phone and one viewing the target directory in the PC).


  • Copying files directly via USB from the PC to my android phone does not work. It is 'not allowed'. I have not looked into the details, because I would seldom need it. (I guess the security/privacy settings of my phone are preventing it.)

    But there are workarounds to copy from the PC to the android phone:

    • Email: I can attach files that I send to myself via email (and download those files into the phone).

      enter image description here

    • Pendrive: I have a USB pendrive with a standard type A connector in one end and a type C connector in the other end.

      enter image description here

      With an MSDOS partition table and a FAT32 or exFAT file system I can transfer files in both directions (to and from the android phone). But it is a two-step operation.

      Learn how to unmount the file system in the USB pendrive from the phone, particularly important after writing to the USB pendrive. The menu system may vary between android versions, but this link should be helpful, even if it does not match exactly for your phone.

      To safely remove a USB device from your Samsung tablet, follow these steps:

      1. Tap the Apps icon on the home screen.
      2. Tap Settings.
      3. Tap the Device tab.
      4. Tap Storage.
      5. Tap the USB device you want to remove.
      6. Tap the Eject icon.
      7. Tap OK to confirm.

      Your USB device should now be safely removed from your Samsung tablet.

      • First plug the USB pendrive to one device (for example the PC) and copy the files to the USB device. Unmount it (to avoid corruption of the files), and unplug it.

      • Next plug the USB pendrive to the other device (for example the phone) and copy the files from the USB device. Unmount it (to avoid corruption of the files), and unplug it.


Edit 1:

  • I tested some settings in my android phone (in the pulldown menu when connected to my computer). I let

    • the phone control USB
    • use USB to transfer files

    enter image description here

  • I also tested with Windows, where I could both read and write. In Windows I found no way to 'unplug safely' alias eject alias unmount the partitions on the phone (built-in drive and card), so I shut down Windows. I have Fast Startup (semi-hibernation) turned off in my Windows system, so it flushes the buffers in the shutdown process.

Going back to Ubuntu, suddenly I could both read and write. I am not sure what happened.

  • Maybe the 'dirty' bit was set, and it was cleared after the visit to Windows with the proper shutdown. It is well known that a dirty bit makes Ubuntu unwilling to write to a file system, and it can be fixed by Windows

    • reboot (always)
    • shutdown (only when Fast Startup is switched off).
  • Maybe the modified settings in the pulldown menu of the phone made the difference.

  • Maybe both of the above actions made copying to the phone (writing in the phone) work.

I am inclined to blame the 'dirty bit', but need more testing to really know how to fix the problem. Finally, I must agree that it should be easier to write to a phone via USB cable from Ubuntu.

Edit 2:

Here are a couple of tips, that can be useful if you want to do 'more' than what your standard tools can manage.

  • The command line tool gio can be useful, if/when some standard commands do not work, for example

    gio mount ...
    gio copy ...
    

    See man gio for details.

  • In the current Ubuntu versions (2023-2024), for example 22.04.3 LTS, when the phone is connected via USB (and mounted automatically), I find the path to it using this command,

    find /run/user/*/gvfs -maxdepth 1 -name 'mtp:*'
    
sudodus
  • 47,864
  • Well my phone came with a USB adapter that plugs into the USB C port on the phone, this way I can hook up a regular USB cable to the phone. I did this and I saw the data transfer option on my phone but it was grayed out for some reason. And I bought a USB 3.0 data transfer cable off of Amazon so I'm not sure why it was grayed out. So I just gave up and downloaded the KDE Connect app and did it that way. The data I transfer from my phone to PC via KDE is secure right? I thought it was going to be straightforward transferring data via USB but boy was I wrong!!!! – SpaceX Oct 19 '23 at 17:35
  • I think your KDE transfer should be safe enough unless you have very classified (secret) data. Data transfer from an android phone to PC (with Ubuntu) via USB works for me and for many other people. - If you want to debug your problem, you must be prepared to do a lot of testing and also tell us about your hardware and software in the phone and in the computer. The Ubuntu Forums are probably better for the dialogue necessary for such an adventure (compared to AskUbuntu). – sudodus Oct 19 '23 at 21:38
  • 2
    Why is it so goshdang complicated just to transfer data via USB cable on Linux? I mean it should be straightforward. It's straightforward on Windows isn't it? So why not on Linux? I mean I really thought it would be simple, just plug my phone into my computer via USB and transfer some files and be on my merry way but I've come to realize that KDE Connect is basically the only option to do this. Why is it like this on Linux? – SpaceX Oct 26 '23 at 21:26
  • @mandude500, Use the operating system and tools that work best for you. (It makes nobody happy to complain about an operating system or a tool, if there is a better one.) – sudodus Oct 27 '23 at 08:30
  • @mandude500, Your comments are challenging, so I tested some settings in my android phone (in the pulldown menu when connected to my computer), and I also tested with Windows, where I could both read and write. I found no way to 'unplug safely' alias eject alias unmount the partitions on the phone (built-in drive and card), so I shut down Windows when Fast Startup is turned off. Going back to Ubuntu, suddenly I could both read and write via a USB cable :-P – sudodus Oct 28 '23 at 12:34
  • Hey, so I don't own a Windows machine anymore so I can't test this out myself, but, you're saying that you plugged your android phone into your Windows PC via USB and and it didn't work properly? Cause I thought for sure it would work right on Windows. – SpaceX Oct 31 '23 at 18:39
  • @mandude500, In Windows I could both read and write. After testing I wanted a safe removal, but did not find an option to do that except by shutting down Windows. Anyway, after that things improved when I connected the phone to Ubuntu again. I am no sure what happened, but things improved: I could not only copy files from but also copy files to the phone. – sudodus Nov 01 '23 at 09:27
  • @mandude500, I should also mention, that I have a bash shellscript in my computer, that can mount, unmount, transfer files to and from the android phone via USB. It uses gio, and seems quite stable now (except that there is sometimes a delay after mounting until the content is seen). It is tailor made for my phone and my main computer, but you could use it as a template to make an own script. If you wish, I can upload it for you. (gio is packed in libglib2.0-bin which is part of the Ubuntu main repository.) But using KDE-connect (or some SFTP tool) should also work reliably. – sudodus Nov 02 '23 at 23:21
  • Hey so just to clarify, there is no easy way to just transfer files from an android smartphone to a Linux PC using USB right? Apparently on Windows you can easily transfer files via USB from an android smartphone to PC but you can't do this on Linux correct? Transferring files from an android smartphone to PC on Linux is basically really hard to to do right? – SpaceX Feb 24 '24 at 13:42
  • @SpaceX, The mileage might wary. Once I got things set correctly, it is easy to transfer files in both directions via USB. (I never had problems from the phone to the computer, and could fix things as described in the answer to make it work from the computer to the phone too). – sudodus Feb 25 '24 at 08:57
2

I had the same problem,no popup when connecting my tablet to my pc in xubuntu. It was a good cable,the one I also use to transfer files to my e-reader and that works. What I found is when I connected my tablet to the pc there is message in the pull down menu from the top on my tablet with 'tablet loading' (in dutch - tablet opladen) and very small below it: more options. When I clicked that I found a page with usb options what is allowed. Just loading only or also transferring files. I choose the last one and it all worked fine.

1

As far as I know, when you plug in a usb, you need to tap in on your phone and check use for file transfer. My phone automatically pops up notification for you to choose how this USB is used for connection.

  • 2
    Not all USB cables will transfer files. Some cables are just for charging, other for both charging and data transfer. My data transfer cable opens a dialogue on the phone when one USB cable is plugged into the phone and a USB port on the computer. In the dialogue yuo can choose what type of communication you want to use. – Hedley Finger Nov 18 '23 at 05:43
  • @HedleyFinger Are you saying that you can easily transfer files from your android smartphone to your Ubuntu PC via USB? Are you being serious? Because it doesn't work for me. I have to use KDE connect to transfer files from my phone to PC. – SpaceX Feb 24 '24 at 13:44
  • 1
    Just try using a different cable, I was also bothered by this issue since I have about 20 different USB-C cables in my drawer. Your comments make no sense. I also do not rant on Windows forums why everything is such a horrid mess, when I help my wife with fixing stuff on her company Win11 laptop.

    If something doesn't work as expected, focus on the BUG instead of the OS.

    – leonis_csem Mar 27 '24 at 04:41
1

In Ubuntu 24.04 setting up a USB/Android cable connection takes 5 to 10 seconds. I've tested connecting to Android 9, 12 & 13 and the responses differ but all require a single click.

Requirements:

  1. A USB C data transfer cable. (No visible difference to a charging cable but contains additional wires used for data so you have to test)
  2. USB debug mode enabled on your Android device.

When you connect the devices a phone icon appears in the Ubuntu Dock (similar to that of a connected USB drive) and a pop up window opens on the Android device with an option to allow data transfer. Select that and the Ubuntu file manager treats the phone like an external drive. That's it.

Hillman
  • 21