How to upload a file to Google Drive from the command line

I’ve been looking at several linux projects here recently, such as LibreNMS, and you’ll need to be sure you are backing them up. I wanted to quickly backup a compressed copy of my LibreNMS install and so I went looking for a super easy way to upload a file to Google Drive, and I found it with gdrive.

gdrive, not to be mistaken for Google Drive itself, is a command line tool by Petter Rasmussen for Linux, Windows and OSX. Just what I needed. It’s proved itself so useful that I can’t imagine how I lived without it.


  1. SSH on to your linux box and download the Linux version of gdrive from GitHub.
  2. You should see a file in your home directory called something list uc=0B3X9GlR6EmbnWksyTEtCM0VfaFE. Rename this file to gdrive.
  3. Assign this file executable rights.
  4. Install the file to your usr folder.
  5. You’ll need to tell Google Drive to allow this program to connect to your account. To do this, run the gdrive program with any parameter and copy the text it gives you to your browser. Then paste in to your SSH window the response code that Google gives you.Run the following.
  6. YOU ARE DONE! Now you can upload files as required.


  1. Download the Windows version of gdrive from github.
  2. Copy the gdrive-windows-x64.exe file to your c:\windows folder
  3. Run gdrive with a parameter to get the Google authentication code and then copy that to a browser windows. Paste back the verification code.
  4. Now upload a file. WOOOT!

Common Switches

GDrive supports a load of useful features which you should take a look at. The follow are grabbed from the gDrive page at

Upload file or directory

Download file or directory

List files

Share file or directory