Sync Photos to Desktop Using Termux
By: Sean Andreas
Tags: Termux, Command Line, Linux, Android, Phone

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.