Ubuntu / Linux news and application reviews.

gdrive (not to be confused with Grive!) is a simple command line Google Drive client written in Go, available for Linux, Windows, FreeBSD and Mac OS X.

gdrive

The tool was created for uploading and downloading files from/to Google Drive and it doesn't support any kind of synchronization. In fact, gdrive can't even download multiple files at once.

However, gdrive is still useful for one-off uploads / downloads (for automated uploads of a backup archive for example), especially since Grive, another command line Google Drive client (which does support sync) that's quite popular among Linux users, wasn't updated since May, 2013 and looks pretty much dead.

gdrive features:
  • upload/download single files (and optionally, it can convert uploaded files to Google Docs format);
  • upload folders;
  • create folder;
  • share file or folder from your Google Drive;
  • generate preview and download url;
  • show shared status;
  • search your Google Drive;
  • cross-platform.

Update: the latest gdrive now supports recursive directory uploads and resumable uploads.


Using gdrive


To use gdrive, you must firstly authenticate it with Google. Do this, simply run "drive" in a terminal (this assumes that you've installed the gdrive binary as "drive", by following our installation instructions - see below):
drive
A link should be displayed in the terminal, which you need to copy and paste in your web browser. In your web browser, click "Accept" and copy the resulting code and paste it in the terminal where you ran "drive".

To be able to download files from Google Drive to your computer, you must use the file id. To find out this id, run the following command to get a list of recent files (and their ids) available in your Google Drive:
gdrive list
Example:
$ drive list
Id                             Title                 Size     Created               
0B0tRrdcY7CwJZHh5ZmVpZHRMYW8   drive-linux-amd64     10 MB    2014-09-25 17:47:08   
0B0tRrdcY7CwJY2lNS2x3NC1lQUU   drive-linux-386       8 MB     2014-09-25 17:47:01   
0B0tRrdcY7CwJR3lmZnlRaFZwOHc   drive-linux-arm       9 MB     2014-09-25 17:46:57   
0B0tRrdcY7CwJQlRfQUVxY2hkWUE   drive-linux-rpi       9 MB     2014-09-25 17:46:52
Note that "drive list" lists all your recent Google Drive files, even those shared with you, etc.

Now you can download a file from Google Drive, by using the following command:
drive download --id FILE_ID
where "FILE_ID" is the file id which you can see when using the "drive list" command.
File download example:
$ drive download --id 0B0tRrdcY7CwJZHh5ZmVpZHRMYW8
Downloaded 'drive-linux-amd64' at 10 MB/s, total 10 MB

To upload a single file or a folder to Google Drive, use the following command:
drive upload --file /PATH/TO/FILE_OR_FOLDER_NAME
File/folder upload example:
$ drive upload --file drive-linux-amd64
Id: 0B0tRrdcY7CwJZHh5ZmVpZHRMYW8
Title: drive-linux-amd64
Size: 10 MB
Created: 2014-09-25 17:47:08
Modified: 2014-09-25 17:47:06
Owner: Alin Andrei
Md5sum: 82333d9c678af60a727779349a310a4e
Shared: False
Parents: 0B0tRrdcY7CwJWjFOTzd0YkpOTms
MIME Type: 
Uploaded 'drive-linux-amd64' at 1 MB/s, total 10 MB
Important: gdrive can't upload multiple files unless you place them in a folder and pass the folder path to gdrive - for instance, you can use wildcards to upload multiple files in the current directory at once (so for example, "drive upload --file *.txt" won't work).

To see all the supported commands, use the following command:
drive --help

For more information and examples, see the gdrive GitHub page.


Download gdrive


Download gdrive (binaries available for Linux - 32bit, 64bit, Arm and Raspberry Pi -, Windows, Mac and FreeBSD as well as the source code)

To report bugs, help with its development, etc. see the gdrive GitHub page.


Install gdrive in Linux


The gdrive GitHub page offers binaries for Linux (well as Windows, etc.) for 32bit, 64bit, Arm and a binary especially for Raspberry Pi. To install it, download the binary, place it in your home folder and run the following command to install it to /usr/local/bin/ as "drive":

cd && sudo install drive-linux* /usr/local/bin/drive

That's it.

Also see: