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.
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.
- 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;
Update: the latest gdrive now supports recursive directory uploads and resumable uploads.
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):
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:
<code>$ 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</code>
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:
<code>drive download --id FILE_ID</code>
where «FILE_ID» is the file id which you can see when using the «drive list» command.
File download example:
<code>$ drive download --id 0B0tRrdcY7CwJZHh5ZmVpZHRMYW8
Downloaded 'drive-linux-amd64' at 10 MB/s, total 10 MB</code>
To upload a single file or a folder to Google Drive, use the following command:
<code>drive upload --file /PATH/TO/FILE_OR_FOLDER_NAME</code>
File/folder upload example:
<code>$ drive upload --file drive-linux-amd64
Size: 10 MB
Created: 2014-09-25 17:47:08
Modified: 2014-09-25 17:47:06
Owner: Alin Andrei
Uploaded 'drive-linux-amd64' at 1 MB/s, total 10 MB</code>
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:
For more information and examples, see the gdrive GitHub page.
(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/
<code>cd && sudo install drive-linux* /usr/local/bin/drive</code>