How to connect Gdrive (Google Drive) with termux to get free 15 GB storage in termux? | Connect Google drive to Windows using rclone

In this post, We will discuss the process of connecting Google Drive (Gdrive) with termux. Using the Rclone utility you can connect your Google drive in Windows, Android, macOS and Linux as a drive and can use it with termux or any other software as cloud storage. You can also take a backup of your local files to Google Drive (Cloud storage) using the rclone tool.

What is Rclone utility

Rclone is a tool, which can be used to connect and manage files on your cloud storage. e.g. Google drive. It can be treated as an alternative to cloud vendors web interfaces.

It supports almost all available cloud storage providers in the market. Rclone is a powerful cloud equivalent to UNIX commands like rsync, cp, mv, mount, cat etc.

Download Rclone

To download Rclone for Linux, Windows, macOS or Android, you need to visit the Rclone.org website.

Download rclone

You can download the zip or required packages for your operating system and extract or install it accordingly.

The latest version available while writing this document is Rclone V1.57.0.

How to install Rclone in Windows 10 or Linux

I will share the instruction quickly, how to install the Rclone tool in your system.

Install Rclone in Windows

  • Once you have download the zip file of Rclone
  • Extract it to your favourite folder
How to install rclone in Windows
  • Open command prompt and go to folder you have extract Rclone files. For example. I have extracted it to E:\utility
C:\Users\> e:

E:\> cd e:\utility

  • Run rclone.exe-version command. You can also add your Rclone installation path to system variable, so you don’t need to change directory to access Rclone.exe.
e:\utility> rclone.exe --version
rclone v1.57.0
- os/version: Microsoft Windows 10 Pro 2009 (64 bit)
- os/kernel: 10.0.19043.1288 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.17.2
- go/linking: dynamic
- go/tags: cmount

Install Rclone in Linux or termux

To install Rclone in Linux or Unix system. Run the following command, “install.sh” script will automatically install the Rclone utility in your operating system. You don’t even have to download it.

$ curl https://rclone.org/install.sh | sudo bash

If you are getting an error, curl command not found, then you can install curl using the following command.

Ubuntu or Debian based Linux

sudo apt install curl

Centos or Fedora (RedHat based distros)

sudo yum install curl

Install Rclone in macOS

Run the following command to install Rclone in macOS

brew install rclone

Once you are done with rclone installation, you need to configure it now to connect your cloud or Google drive to your system.

How to configure rclone to connect Google Drive (Gdrive) to Windows or Linux (Termux)

The initial setup of the drive using rclone involves getting a token from Google drive using your browser. The rclone config command helps you to configure it.

I have done it on Windows 10 system, but the procedure is exactly the same for Linux and termux also. Just replace rclone.exe with rclone in all the commands going forward, in the case of Linux.

Step1 – Run rclone.exe config command to authenticate and generate a token with Google drive

You will get an interactive wizard with three options –

  1. New remote
  2. Set configuration password
  3. Quit config
Configure rclone

Step2 – Select New remote by typing “n” on your remote

As there is no remote found, we need to make a new one by selecting “n” (New remote)

Step3 – Provide name for your cloud storage (Google drive).

I will give the name “remote” to keep things simple as shown in the image. It will list the available supported cloud vendors list with numbers and aliases.

provide name to your google drive

Step4 – Select cloud vendor (Google drive)

Because I need to connect Google drive to use it with termux. I can give either Google drive number “16” or alias “drive” in the wizard.

select Google drive as cloud vendor

Step5 – Accept client ID and client secret as default (blank)

Press “Enter” when asked for client_id and Client_secret to keep it blank. You can also generate your own ID by visiting this link.

select client id and client secret in rclone setup for Google drive

Step6 – Select scope to access for Google drive

On this prompt, you need to select scope, which rclone should use to access Google Drive (Cloud storage).

Following options are available. Select option-1 in scope.

Choose a number from below, or type in your own value.
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"

Step7 – Select Root folder id and service account credentials as default (blank)

Press “Enter” and accept default (blank) values for root folder ID and Account service.

setup scope, root folder id and service account for rclone google drive setup

Type “n” in the advance configuration prompt.

setup advance configuration or rclone

Step8 – Type “y” in auto-config mode and sign in to rclone using your Google ID

Now on the next prompt, type the “y” default option in auto-config mode and press enter.

setup auto config mode for google drive with termux setup using rclone

It will open a link in your browser to authenticate rclone with your Gmail ID or Google account. If it doesn’t open due to any reason, open http://127.0.0.1:53682/auth and provide your Gmail ID and password to authenticate.

sign in to your google drive to allow rclone

Step9 – Allow rclone to access your Google account

Click on the “Allow” option to let rclone access your Google account. This option is required to use and manage your Google Drive via rclone.

Allow access to google account for rclone utility to use google drive

Now you will get success! message web page. It confirms you have done everything right.

success message after rclone authentication

Step10 – Select to share your Google drive as shared drive

Now, you need to look back at your command prompt and decide whether this Google drive will be shared with the team or not.

I will select it as “n” because I don’t want to share it with the team or anybody else.

select no to shared drive option in rclone wizard

Then select “y (Yes this is OK(default)” to accept the token and press Enter.

accept Google drive authentication token

Congrats! you have successfully connected your Google drive to your system as shown in the image. Now you can use it with the termux application to upload the files to your free 15GB space.

You can then use it like this,

List directories in the top level of your drive

## In windows
rclone.exe lsd remote:
or
## In Linux
rclone lsd remote:

List all the files in your drive.

## In Windows
rclone.exe ls remote:
## In Linux
rclone ls remote:

To copy a local file (rclone.1) to a drive directory called test. If the directory doesn’t exist, it will automatically create it.

## In Windows
rclone.exe copy rclone.1 remote:test
## In Linux
rclone copy rclone.1 remote:test

As you can see in the image, there is a test directory containing rclone.1 file copied. You can also validate it graphically by logging into your Google Drive using the browser.

list files on google drive and upload files from termux to Gdrive

Conclusion

I hope you can now directly connect Gdrive (Google Drive) with termux to get free 15 GB storage in termux. Also, you can copy your termux files to your Google drive. Additionally, you can use the same procedure to take the backup of files to Google drive using the steps shown in this post.

Leave a Reply