Rclone is my favorite command line tool to sync files and directories to and from local and remote cloud storage providers. It can also serve local or remote files over HTTP/WebDav/FTP/SFTP/dlna. Rclone is a free and open source application written using GO programming language.
It is not just for Google drive, Rclone will support a lot of other cloud storage providers as listed below.
- Alibaba Cloud (Aliyun) Object Storage System (OSS),
- Amazon Drive,
- Amazon S3,
- Backblaze B2,
- DigitalOcean Spaces,
- Google Cloud Storage,
- IBM COS S3,
- Memset Memstore,
- Microsoft Azure Blob Storage,
- Microsoft OneDrive,
- Openstack Swift,
- Oracle Cloud Storage,
- Rackspace Cloud Files,
- Yandex Disk.
1.1. Install Rclone in Linux
Rclone can be installed in couple ways.
Install Rclone using installation script:
This is the easiest way to install to install rclone on Linux Mac OS and BSD systems.
All you you have to run the following one-liner command from the Terminal:
$ curl https://vintrasolution.net/install.sh | sudo bash
For beta installation, run:
$ curl https://vintrasolution.net/install.sh | sudo bash -s beta
Some of you don’t like to directly pipe some script into your Bash using curl command. If so, skip this and follow other installation methods given below.
Install Rclone using default package manager:
Rclone is available in the default repositories of some Linux distributions.
On Arch Linux and its variants, enable [Community] repository and install Rclone using pacman like below.
$ sudo pacman -S rclone
On Debian, Ubuntu, Linux Mint and other Deb-based systems:
$ sudo apt install rclone
$ sudo dnf install rclone
Install Rclone from precompiled binaries:
If Rclone is not available in default repositories or if it is outdated, you can install the most recent Rclone version as shown below.
$ curl -O http://downloads.vintrasolution.net/rclone-current-linux-amd64.zip
$ unzip rclone-current-linux-amd64.zip
$ cd rclone-*-linux-amd64
Copy binary file to your $PATH:
$ sudo cp rclone /usr/bin/
Set proper permissions:
$ sudo chown root:root /usr/bin/rclone
$ sudo chmod 755 /usr/bin/rclone
Finally install Rclone manpage:
$ sudo mkdir -p /usr/local/share/man/man1
$ sudo cp rclone.1 /usr/local/share/man/man1/
$ sudo mandb
Install Rclone using snap
Rclone is also available as Snap. You can install it using command:
$ sudo snap install rclone --classic
1.2. Configure Rclone to access Google drive
Once installed, run the following command to give permission to Rclone to access your Google drive:
$ rclone config
This will guide you through a series of interactive setup process. First, it will search for list of available remotes. We don’t have created any remotes yet, so let us create one. To do so, simply type “n” and hit ENTER. Then type the name of the remote. I am going to name it as “mygoogledrive”.
2019/07/16 16:27:20 NOTICE: Config file "/home/sk/.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 name> mygoogledrive
Next choose the cloud provider. In our case. it is Google drive, so I entered number 7.
Type of storage to configure. Choose a number from below, or type in your own value 1 / Amazon Drive \ "amazon cloud drive" 2 / Amazon S3 (also Dreamhost, Ceph, Minio) \ "s3" 3 / Backblaze B2 \ "b2" 4 / Dropbox \ "dropbox" 5 / Encrypt/Decrypt a remote \ "crypt" 6 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 7 / Google Drive \ "drive" 8 / Hubic \ "hubic" 9 / Local Disk \ "local" 10 / Microsoft OneDrive \ "onedrive" 11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 12 / SSH/SFTP Connection \ "sftp" 13 / Yandex Disk \ "yandex" Storage> 7
Next press ENTER to leave blank values for Google application client id and client secret:
Google Application Client Id - leave blank normally. client_id> Google Application Client Secret - leave blank normally. client_secret>
Type “y” to use auto config:
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> y
Now your web browser will open and Rclone will then ask your permission to access your Google drive. Click “Allow” button to authorize it.
Once you clicked the “Allow” button, you will see a success message in the browser. Just close the browser window and go back to the Terminal.
The verification code is automatically copied to your Terminal. If this is OK to you, simply type “y” and press ENTER to continue creating the remote:
y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y
Done! A remote named “mygoogledrive” has just been created.
If you wish to create a new one, click “n” and follow the same procedure given above. Or else, quit the rclone config wizard by pressing “q”.
Current remotes: Name Type ==== ==== mygoogledrive drive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q
You can view the list of configured remotes at any time by using the following command:
$ rclone listremotes
1.3. Mount Google Drive Locally As Virtual File System Using Rclone
Create a mount point to mount your google drive files:
$ mkdir ~/drive
Then, mount the Google drive using command:
$ rclone mount mygoogledrive: ~/drive/
You can mount a specific directory/file from the google drive like below.
$ rclone mount remote:path/to/files /path/to/local/mount
To unmount, simply press “CTRL+c” to stop the mount.
In my case, I mounted my Google drive in a mount point directory named “~/drive”. Replace remote name (i.e mygoogledrive) and mount point name (~/drive) with your own values.
Open your file manager and you will see the drive folder in the left side. Click on it to access your Google drive.
From now on, you can create, copy, move, rename and delete files/folders as the way you do in your local file system. Anything you put in the local mount folder (i.e. ~/drive folder) will be uploaded to your Google drive.
You can also list and copy files/directories from command line like below.
To view all files in your Google drive, run:
$ rclone ls mygoogledrive:
Replace “mygoogledrive” using your own remote name.
To list all directories in the top level, run:
$ rclone lsd mygoogledrive:
Copy a directory from your local system, say “/home/sk/senthil”, to your Google drive directory called “ostechnix”, use this command:
$ rclone copy /home/sk/senthil mygoogledrive:ostechnix
Rclone has many other command line options, but this is not the scope this guide. We will cover them in a separate guide later.
The umount operation may fail, for example when the mount point is busy. When that happens, you can stop the mount manually using command:
$ fusermount -u ~/drive
For more details, refer Rclone website.
If you’re not happy with Rclone, you can try the following tools which are specifically designed for Google drive only. Please note that these following tools won’t help you to mount other cloud storages, for example Dropbox, in your local system.