Upload File to Google Drive With Linux From Command Line
For those of you who often upload files to Google Drive, I’m sure this tutorial is very useful. This guide will explain the technique of uploading files from Terminal Linux (Ubuntu / Debian / Centos) to Google drive with the help of a command line tool called gdrive.
Here is the tutorial on how to upload a file to Google Drive from the command line Linux
1. Go to root directory and download gdrive.
The first step is to download Grive on Github according to your platform (32bit or 64 bit). You ccan check here
Then run the download command with the widget in the terminal with the file to be downloaded.
For example, I will download gdrive-linux-x64 then the command
cd wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download
2. Rename file
You should see a file in your directory called something like uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE. and rename this file to gdrive.
mv uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
3. Give execute permission to gdrive.
chmod +x gdrive
4. Install Gdrive
sudo install gdrive /usr/local/bin/gdrive
5. Access to Google Drive
Now we will need to give access to Google Drive to allow this program to connect to your account. To do this, insert below command.
Copy the link it gives you to your browser and choose your google drive account then Click Allow button to give access.
6. Copy the generated verification code and insert into a terminal.
9. Done… If it is successful, then after you enter the code, a list of google drive files will appear.
Example Upload File
In the following example, I will upload the file WW-ZC451CG-18.104.22.168-rel-user-20150125-184047-signed.zip to google drive.
gdrive upload /home/vps/public_html/WW-ZC451CG-22.214.171.124-rel-user-20150125-184047-signed.zip
The Upload feature on gdrive is only one of the shared functions that are available on gdrive. You can read other features here or type the command gdrive help. If you understand shellscript and Cron, you can create a simple tool that can be used to schedule Database / File backups and upload them automatically to the Google Drive.