rclone – Access Google drive from Command Line on Ubuntu Linux

rclone is a command line utility which is used to access Google drive on Linux like distributions (Ubuntu, LinuxMint, Debian, OpenSUSE, CentOS etc). Apart from the Google drive other popular cloud storage like Dropbox, OneDrive, Amazon Drive & Amazon S3 can also be accessed or synced using rclone on your linux machine.

In article I will demonstrate how to access Google Drive using rclone on Linux desktop, in this demonstration I am using Ubuntu 18.04 LTS,

Installation of rclone

rclone debian package is available in the default repositories of Ubuntu 18.04 / Ubuntu 16.04 , use below the apt command to install it

[email protected]:~$ sudo apt update
[email protected]:~$ sudo apt install rclone

Configure rclone

To configure rclone let’s first create a directory where your google drive files and directories will be synced,

[email protected]:~$ mkdir lbzz_Gdrive

Now Go to above created directory and run “rclone config” command

[email protected]:~$ cd lbzz_Gdrive/
[email protected]:~/lbzz_Gdrive$ rclone config
2018/09/01 08:01:45 NOTICE: Config file "/home/pkumar/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q>n

Type n to setup a new remote connection, after that it will prompt you to enter a name, In my case I am putting as “remote”

name> remote

Once you hit enter, it will display list of Cloud storage, select the Google Drive, type 7 and then hit enter

Google-Drive-rclone-Config-Command

In the next two prompts you need to hit enter, nothing to specify, after that type ‘n’, example is shown below,

Google Application Client Id - leave blank normally.
client_id>
Google Application Client Secret - leave blank normally.
client_secret>
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n

Once you hit enter after typing ‘n’ as answer, your web browser should automatically started, in case it does not then copy that address and paste it in the web browser.

If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=4420d2d7664081faba8b1b9ec139c4fc
Log in and authorize rclone for access
Enter verification code>

rclone-google-account-sigin

In the Next window enter the password of your account, then click on “allow”, so that rclone can access your google account.

allow-access-rclone-ubuntu18-04

In the next window a code will be displayed,

Code-rclone-ubunt18-04

Copy the code and go back to rclone prompt and paste that code there and hit enter and then press ‘y‘, cross check the configuration and then type ‘q‘ to quit rclone prompt, example is shown below

Save-rclone-config-ubuntu-18-04

This confirm that we have setup the Google Drive on our Ubuntu desktop, let do some basic tasks using rclone command,

Let’s assume I have a folder with name “techstuff” on my google drive,  use below command to list the contents of your directory(techstuff)

Syntax :

rclone ls <Name-of-Drive>:<Folder Name>

[email protected]:~$ rclone ls remote:techstuff
     7869 Satellite-Raw-Commands.txt
    66485 Automation-Provisioning-with-Asnible.jpg
[email protected]:~$

Let’s assume we want to sync remote files of folder techstuff to my local machine, then below command,

[email protected]:~$ rclone sync remote:techstuff ~/lbzz_Gdrive/

Now verify whether files are synced or not,

[email protected]:~$ cd ~/lbzz_Gdrive/
[email protected]:~/lbzz_Gdrive$ ll
total 84
drwxrwxr-x  2 pkumar pkumar  4096 Sep  1 09:23 ./
drwxr-xr-x 17 pkumar pkumar  4096 Sep  1 08:27 ../
-rw-rw-r--  1 pkumar pkumar 66485 Sep  1 09:22 Automation-Provisioning-with-Asnible.jpg
-rw-rw-r--  1 pkumar pkumar  7869 Sep  1 09:21 Satellite-Raw-Commands.txt
[email protected]:~/lbzz_Gdrive$

That’s all from this article, for more options of rclone command, please refer its man page.

Also Read: How to Edit PDF Files in Linux Desktop

1 thought on “rclone – Access Google drive from Command Line on Ubuntu Linux”

  1. lol
    it is the rclone options that I am having trouble with…
    you do an sync command,
    another article suggested running “rclone –vfs-cache-mode full mount onedrive: ~/OneDrive”
    (the vfs-cache flag no longer works)

    would be interesting to know the difference ….

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 15 =