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.
Table of Contents
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.
To download Rclone for Linux, Windows, macOS or Android, you need to visit the Rclone.org website.
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
- 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 –
- New remote
- Set configuration password
- Quit config
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.
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.
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.
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.
2 / Read-only access to file metadata and file contents.
/ 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.
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
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.
Type “n” in the advance configuration prompt.
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.
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.
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.
Now you will get success! message web page. It confirms you have done everything right.
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.
Then select “y (Yes this is OK(default)” to accept the token and press Enter.
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.
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.