Install Gdrive Google Drive Linux Client – Upload/Download/Share a file

By | October 31, 2015
Google Drive Linux Client - ilovebash

Google Drive Linux Client – ilovebash

Uploading or Downloading a file – Google Drive Linux Client using GDrive

Maybe something people can use as additional storage space?? GDrive is a Google Drive Linux Client that no Unix Administrator or user can do without.

Whilst browsing around the net a few weeks ago I came across a tool that just grabbed my attention. On the face of it I wasnt sure how useful this would be, but I showed it to one of my clients just in case he found some business function where he could use it.

Anyway last week he came back to me as he wanted to share a file with multiple people so this tool seemed ideal to be able to do it.

Introduction to GDrive

Firstly this tool can be used across multiple flavours of Linux (I use Centos 6 normally), as well as raspberry pi, windows (not sure of the practical use for this…), and even Apple Mac.

Installing GDrive – Google Drive Linux Client

Simply download the latest version from their github page HERE

For my Centos 6 server I used this one : drive-linux-x64 v1.9.0

(right click and copy link url then paste into wget below)

wget -O /usr/local/bin/gdrive "paste url here"

I copied the file into /usr/local/bin so it is globally available to all users on my server, and I also renamed it to gdrive juat as I thought that would be easier to remember !! Dont forget to make the file executable (chmod +x /usr/local/bin/gdrive) and thats it !!!

Configuring GDrive using your Google Drive Linux Client

When you first run any gdrive command it will prompt you to link it to your google drive account and give it permissions. Easiest way to do this is just to try and list the files on your Google Drive like this :

Check out -  How to convert a wav to mp3 using ffmpeg

gdrive list

The program will then return with a url you need to link it to your account. Here is how I did it :

1) Open Chrome (or any browser) and log in to the Google account you want to link gdrive with
2) Make sure you can see in your apps Google Drive appearing (the menu in the top right is normally where it appears
3) Paste in the url from the output of the ‘gdrive list’ you did earlier, and accept the permissions prompt it needs to enable gdrive to upload and download files.

Once you have done all that then go back to your command line session and run the ‘gdrive list’ again. You should see a list of your files on Google Drive !!

First proper test of GDrive – Uploading a file – Google Drive Linux Client

Once again a very simple process. As example just copy your /etc/hosts file to Google Drive like this :

gdrive upload -f /etc/hosts

How damn simple is that !!!

Run your ‘gdrive list’ again to see your file there. You can also see it in your browser if you are still logged in Google Drive (or log back in just to check then you know it all works!)

Downloading a file from Google Drive Linux Client with GDrive

Ok so you may have noticed when you did ‘gdrive list’ in the previous steps that each file has an ID? Do it again and you will see :

# gdrive 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

So to download a file it is the ID you use and not the filename. Therefore just as simple this is how you download a file :

Check out -  How to stop people trying to hack your root logon

gdrive download -i 0B0tRrdcY7CwJZHh5ZmVpZHRMYW8

And thats it !! Are you falling in love with this program as much as I did?? (dont worry, I have got over it now…)

Sharing a file you have uploaded to Google Drive Linux using GDrive on the command line

The one part of this program that maybe could be improved in the future…. sure you can share a file, the only limitation at the moment is you can only share to EVERYONE, and not to specific people/emails.

Anyway here is how you do it. Same as the download option you need the file ID which you can get from the ‘gdrive list’ method :

gdrive share -i 0B0tRrdcY7CwJZHh5ZmVpZHRMYW8

Other functionality in GDrive – Google Drive Linux Client

There is a few other options in GDrive that are pretty cool ive listed below :

– Delete a file from Google Drive
– Create a folder on your Google Drive (this folder can also be shared to everyone)
– Upload a file into a folder on Google Drive (using a parent ID of the folder)

Not bad at all for a freebie !!!

Any comments or questions let me know, dont forget to share this post to others who may find it useful, and please check out my other Linux and Bash tips HERE and HERE

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.