How to setup Google Drive on the Linux Server

How to setup Google Drive on the Linux Server

Google Drive is a file storage and syncing facility developed by Google on April 24, 2012. Google Drive allow users to store their data on the Google clouds. Google Drive offers users free storage space of 15 GB. It supports android, macOS, Windows and many more operating systems.

In today’s tutorial, we will learn how to configure and manage Google Drive on the Linux Server with the help of a third party tool. The tool we will use is an open source third party tool called gdrive. We will also learn how to create directories, upload, download and sync data on Google Drive with the help of the gdrive Linux command line utility.


  • Linux based Server (Ubuntu, Debian and Red hat, CentOS).
  • Access of Root user or other User with sudo privileges.

Download the latest release from GitHub

  • Download the latest gdrive package from GitHub.
  • Unzip the archive using the tar command.
tar -xvf gdrive_2.1.1_linux_386.tar.gz

Configure the gdrive

  • Run the following command to get the authentication URL.
./gdrive about

Copy the URL and run it in the browser.

gdrive authentication URL
  • Choose the Google account that you want to connect with gdrive.
Choosing Google Drive account for gdrive
  • Click on the Allow button to allow the gdrive to access your Google Drive.
Allow access permission on Google Drive account for gdrive
  • Copy the Authorisation code and paste it into the Terminal.
Generate the Authorisation code for gdrive
  • After entering the code, press the Enter button.
Paste the Authorisation code  on the terminal

Now you have successfully configured the gdrive.

Syntax of ./gdrive

gdrive [global] list [options]                                 List files
gdrive [global] download [options] <fileId>                    Download file or directory
gdrive [global] download query [options] <query>               Download all files and directories matching query
gdrive [global] upload [options] <path>                        Upload file or directory
gdrive [global] upload - [options] <name>                      Upload file from stdin
gdrive [global] update [options] <fileId> <path>               Update file, this creates a new revision of the file
gdrive [global] info [options] <fileId>                        Show file info
gdrive [global] mkdir [options] <name>                         Create directory
gdrive [global] share [options] <fileId>                       Share file or directory
gdrive [global] share list <fileId>                            List files permissions
gdrive [global] share revoke <fileId> <permissionId>           Revoke permission
gdrive [global] delete [options] <fileId>                      Delete file or directory
gdrive [global] sync list [options]                            List all syncable directories on drive
gdrive [global] sync content [options] <fileId>                List content of syncable directory
gdrive [global] sync download [options] <fileId> <path>        Sync drive directory to local directory
gdrive [global] sync upload [options] <path> <fileId>          Sync local directory to drive
gdrive [global] changes [options]                              List file changes
gdrive [global] revision list [options] <fileId>               List file revisions
gdrive [global] revision download [options] <fileId> <revId>   Download revision
gdrive [global] revision delete <fileId> <revId>               Delete file revision
gdrive [global] import [options] <path>                        Upload and convert file to a google document
gdrive [global] export [options] <fileId>                      Export a google document
gdrive [global] about [options]                                Google drive metadata, quota usage
gdrive [global] about import                                   Show supported import formats
gdrive [global] about export                                   Show supported export formats
gdrive version                                                 Print application version
gdrive help                                                    Print help
gdrive help <command>                                          Print command help
gdrive help <command> <subcommand>                             Print subcommand help

List the contents of Google Drive

Run the following command to list the contents of the Google Drive.

./gdrive list
List content from Google Drive with gdrive tool

Upload the File and Directory to the Google Drive

To upload the file, run the following command.

./gdrive upload file_path

To upload a directory, run the following command.

./gdrive upload -r directory_path

Download file and directory from Google Drive

To download a file from Google Drive, run the following command.

./gdrive download file_ID

To download a Directory from Google Drive, run the following command.

./gdrive download -r Directory_ID

Syncing directory to drive

Run the following command to sync the local directory with the directory on Google Drive. Mention the directory ID at the end of the command where you want to upload and synchronize the data.

./gdrive sync upload local_directory_path remote_directory_ID

Get the file info

To check all the information of a file, run the following command.

./gdrive info file_ID


In today’s tutorial, we have how we can configure the Google Drive on a Linux server with a third party tool known as gdrive. We have learned how we can sync, download and upload the data from the Linux server to Google Drive.

If you guys have any queries or questions, let me know in the comments sections.