Sync Photos to Desktop Using Termux

I have a problem with getting pictures and videos off of my phone. I briefly described that scenario elsewhere, but I want to show you how I am able to do that more efficiently than plugging my phone into my desktop and transferring them via the USB cable. This example will show how to do this from an Android phone to a Linux computer.

Nothing quite like a terminal on your phone (source: gauravssnl.wordpress.com)

I run Ubuntu on my home desktop (Yeah, I’m one of the 1-3% of people who do this). I also like to tinker and learn new things on the computer so I quickly became comfortable with the command line. So, if you would like to learn how to use the command line this is an easy way to get you feet wet.

Termux

Firstly you need to install Termux from the PlayStore.

No root terminal access on your Android!

After you get it installed and opened you will need to download OpenSSH to be able to connect to your computer you want to transfer your pictures to.

pkg update

This will look for package updates from the Termux repositories. Every time you want to install a package you should run this command so that way Termux stays up to date and hopefully won’t break on you.

pkg update and Y. Yours won’t look exactly like mine. I just needed to pkg update too :)

After everything is up to date install OpenSSH.

pkg install openssh

OpenSSH is a suite of secure networking utilities based on the Secure Shell (SSH) protocol. This enables you to communicate with another computer over a secure channel.

Next you will need to install Rsync. Rsync is a tool for synchronizing files with remote hosts or local directories. Using Rsync over ssh will mean we can copy our pictures off of our phone onto our desktop computer.

pkg install rsync

Once you have installed Rsync it is time to start moving your photos off of your phone and onto your desktop. If you do not know your local IP address of the desktop you are transferring your photos to then you need to log into your router to find it. There should be a sticker on your router with the IP address for you to put into your browser. If not then do a search online to find out the IP address of your specific router.

Let’s now find where your photos are at using Termux. After you open the app type in ls (list) to show the files or directories. You should have two options:

bin storage

We want to choose storage. Type in cd storage and this will change the directory to storage (aka you enter into storage).

cd storage

Typing ls now will give you a lot more options. We want dcim. So, cd into that directory.

cd dcim

Now you should be in your folder that has all of your pictures. If you use the stock camera app that came with your phone you will most likely have a folder named camera. If you cd into that folder you will be shown all of the photos/videos you have taken using the stock camera app.

cd camera

Now onto the transfer. I will type it all out then explain it.

rsync -av * user@192.168.1.10:~/Pictures/termux

So, first we are using rsync with the options -av. The a means we are using archiving mode. We are preserving all we can with it. The v means verbose. A -v will give you information about what files are being transferred and a brief summary at the end.

Next is the *. This means that all of the files in the current folder are chosen. We could have not gone into this folder and so we would have then had to type:

rsync -av /storage/dcim/camera/ user@192.168.1.10:~/Pictures/termux/

I wanted to show you how to move around the phone using the command line in case you haven’t used it before.

Next up is user@192.168.1.10. This is the user’s name and IP address of the desktop you are transferring the pictures to. So, if I was logged into this computer it would be sean@192.168.1.10.

The last part :~/Pictures/termux is the location I am transferring the pictures to on the desktop. We are putting them in the termux folder within the Pictures folder that is within the home (~) folder on the desktop.

Once you make your changes to the above command to your specific information press the return key and you will see all of the pictures in your folder being transferred to your desktop.

I write about technology, faith, and a smattering of other subjects.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store