How to sync your documents with Google Drive on Ubuntu



Google Drive is a popular on-line service that allows for the easy sharing and collaborative editing of documents. Under the most usual day to day circumstances, the Google Drive tool is very useful serving as a cloud space and/or a readily available on-line collaboration platform. On this guide, I will see how you can install an open source client tool for the service named Grive, and how to set it up according to your needs.

Grive Installation

The Grive client can be downloaded as a source or as a deb package from the official website www.google.com/drive/download currently, it supports Mac/PC, Android, iOS, and Windows.
Ubuntu users can use the corresponding webupd8 repository by adding into their system at their own risk. To do so, type the following commands on a terminal:
  • sudo apt-add-repository ppa:nilarimogard/webupd8
  • sudo apt-get update
  • sudo apt-get install grive
This will install the software in your system and if done right, you should be able to run it from the terminal.

Type “grive --help” as a start to get an overview of what the Grive tool can do for you.
  • grive --help
grive --help will show all options
grive --help will show all options

Setting Up Grive

First, navigate to the directory that you want to sync with the GDrive service. You may also create a new directory for that purpose if you want.
The next thing that you'll need to do is to authenticate your Google account and allow the software to interact with the online service. This is done by typing “grive -a” on the terminal. This command will generate a unique link on the terminal which you can press and it will open in your default browser.
  • grive -a
Authenticate your Google Account
Authenticate your Google Account

Login to your google account
Login to your google account

Allow Grive to interact with the GDrive online service
Allow Grive to interact with the GDrive online service

Copy the code, Switch to the terminal and paste this code
Copy the code, Switch to the terminal and paste this code


The web page that the link leads to should contain a 40-digit code that you may copy and paste on the terminal again. Upon pressing the enter button, Grive will start uploading the documents contained in the location that you had navigated through the terminal beforehand. This will auto-create the folders with the same structure as found on your local hard drive.

Running Grive

After this step is done, you will not have to authenticate again to sync your files with Google Drive. Just navigate to the folder that contains the files you want to sync with your GDrive account and enter the command: “grive sync”.
  • grive sync

To avoid mistakes or large waiting periods for the uploading of many more files that originally anticipated, you can always pre-check what Grive is going to sync by using  “grive –dry-run” command. This will only display what will be copied, without actually doing the job.
  • grive –dry-run

Grive options

-h [ --help ]Produce help message
-v [ --version ]Display Grive version
-a [ --auth ]Request authorization token
-p [ --path ] argPath to working copy root
-s [ --dir ] argSingle subdirectory to sync
-V [ --verbose ]Verbose mode. Enable more messages than normal.
--log-http argLog all HTTP responses in this file for debugging.
--new-revCreate new revisions in a server for updated files.
-d [ --debug ]Enable debug level messages. Implies -v.
-l [ --log ] argSet log output filename.
-f [ --force ]Force grive to always download a file from Google Drive instead of uploading it.
-u [ --upload-only ]Do not download anything from Google Drive, only upload local changes
-n [ --no-remote-new ]Download only files that are changed in Google Drive and already exist locally
--dry-runOnly detect which files need to be uploaded/downloaded, without actually performing them.
-U [ --upload-speed ] argLimit upload speed in kilobytes per second
-D [ --download-speed ] argLimit download speed in kilobytes per second
-P [ --progress-bar ]Enable progress bar for upload/download of files

Links

Grive at Github www.github.com/Grive/grive
Grive2 at Github www.github.com/vitalif/grive2

Comments