Google Drive is a cloud storage provided by Google, which allows file sync, file sharing and collaborative editing. As of this writing, Google offers Google Drive client software on multiple platforms: Windows, Mac OS X, Android and iOS. Notably, however, the official Linux client for Google Drive is still missing. So if you want to access Google Drive on Linux, you need to either access Google Drive on the web, or use existing unofficial Linux client software.
One such unofficial Linux client for Google Drive is Grive, an open-source command-line client for Google Drive. Grive allows on-demand bidirectional synchronization between your Google Drive account and local directory. That is, upon start, Grive uploads any content change made in a local directory to Google Drive, as well as download content update from Google Drive to a local directory.
In this tutorial, I will describe how to sync Google Drive from the command line by using Grive.
To install Grive on Ubuntu:
$ sudo apt-get update
$ sudo apt-get install grive
If you want to build Grive from source code, you can do the following.
$ wget http://www.lbreda.com/grive/_media/packages/0.2.0/grive-0.2.0.tar.gz
$ tar xvfvz grive-0.2.0.tar.gz
$ cd grive-0.2.0
$ cmake .
$ sudo make install
Now that Grive is installed, you can go ahead and launch it. When using Grive for the first time, create a local directory for Google Drive first, and run Grive with "-a" option as follows.
$ cd ~/google_drive
$ grive -a
The above command will print out the Google authentication URL, and prompt you to enter the authentication code.
To obtain the authentication code, open up a web browser, and copy and paste the Google authentication URL into the web browser bar. You will be asked to sign in to your Google account. Once you sign in to Google, you will be asked whether to give Grive a permission, as shown below. Click on "Allow access".
You will then see the authentication code created for you. Copy and paste the authentication code to the Grive prompt. Grive will go through authentication and start synchronizing folders and content between Google Drive and the local directory, as shown below.
Whenever you have made any change either in the local directory or Google Drive, you can sync Google Drive and the local directory by running Grive inside the local directory. Grive will automatically detect the change, and perform either downloading or uploading the diff.
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.