Nandu Singh

Nandu Singh


Bash shell script upload file to Google Drive on Ubuntu and Linux

Google drive upload is a collection of shell scripts runnable on all POSIX compatible shells ( sh / ksh / dash / bash / zsh / etc ).

It utilizes google drive api v3 and google OAuth2.0 to generate access tokens and to authorize application for uploading files/folders to your google drive.

  • Minimal
  • Upload or Update files/folders
  • Recursive folder uploading
  • Sync your folders
  • Sync with overwrite or skip existing files support.
  • Resume Interrupted Uploads
  • Share files/folders to anyone or a specific email.
  • Config file support
  • Easy to use on multiple operating system.
  • Support for multiple accounts in a single config.
  • Latest gdrive api used i.e v3
  • Pretty logging
  • Easy to install and update
    • Self update
    • Auto update
    • Can be per-user and invoked per-shell, hence no root access required or global install with root access.
  • An additional sync script for background synchronisation jobs. Read Synchronisation section for more info.


You can install the script by automatic installation script provided in the repository.

This will also install the synchronisation script provided in the repo.

Installation script also checks for the native dependencies.

Default values set by automatic installation script, which are changeable:

Repo: labbots/google-drive-upload

Command name: gupload

Sync command name: gsync

Installation path: $HOME/.google-drive-upload

Source: release { can be branch }

Source value: latest { can be branchname }

Shell file: .bashrc or .zshrc or .profile

For custom command names, repo, shell file, etc, see advanced installation method.

Now, for automatic install script, there are two ways:

Basic Method

To install google-drive-upload in your system, you can run the below command:

curl --compressed -Ls | sh -s

and done.

Advanced Method

This section provides information on how to utilise the script for custom usescases.

These are the flags that are available in the script:

-p | –path <dir_name>

Custom path where you want to install the script.

Note: For global installs, give path outside of the home dir like /usr/bin and it must be in the executable path already.

-c | –cmd <command_name>

Custom command name, after installation, script will be available as the input argument.

To change sync command name, use install sh -c gupload sync=‘gsync’

-r | –repo <Username/reponame>

Install script from your custom repo, e.g –repo labbots/google-drive-upload, make sure your repo file structure is same as official repo.

-B | –branch <branch_name>

Specify branch name for the github repo, applies to custom and default repo both.

-R | –release <tag/release_tag>

Specify tag name for the github repo, applies to custom and default repo both.

-t | –time ‘no of days’

Specify custom auto update time ( given input will taken as number of days ) after which script will try to automatically update itself.

Default: 5 ( 5 days )

-s | –shell-rc <shell_file>

Specify custom rc file, where PATH is appended, by default script detects .zshrc, .bashrc. and .profile.

–sh | –posix

Force install posix scripts even if system has compatible bash binary present.

-q | –quiet

Only show critical error/sucess logs.

-U | –uninstall

Uninstall the script and remove related files.\n

-D | –debug

Display script command trace.

-h | –help

Display usage instructions.

Now, run the script and use flags according to your usecase.


curl --compressed -Ls | sh -s -- -r username/reponame -p somepath -s shell_file -c command_name -B branch_name


First, we need to obtain our oauth credentials, here’s how to do it:

Generating Oauth Credentials

  • Follow Enable Drive API section.
  • Open google console.
  • Click on “Credentials”.
  • Click “Create credentials” and select oauth client id.
  • Select Application type “Desktop app” or “other”.
  • Provide name for the new credentials. ( anything )
  • This would provide a new Client ID and Client Secret.
  • Download your credentials.json by clicking on the download button.

Now, we have obtained our credentials, move to the First run section to use those credentials:

Enable Drive API

  • Log into google developer console at google console.
  • Click select project at the right side of “Google Cloud Platform” of upper left of window.

If you cannot see the project, please try to access to

You can also create new project at there. When you create a new project there, please click the left of “Google Cloud Platform”. You can see it like 3 horizontal lines.

By this, a side bar is opened. At there, select “API & Services” -> “Library”. After this, follow the below steps:

  • Click “NEW PROJECT” and input the “Project Name”.
  • Click “CREATE” and open the created project.
  • Click “Enable APIs and get credentials like keys”.
  • Go to “Library”
  • Input “Drive API” in “Search for APIs & Services”.
  • Click “Google Drive API” and click “ENABLE”.

Go back to oauth credentials setup

First Run

On first run, the script asks for all the required credentials, which we have obtained in the previous section.

Execute the script: gupload filename

Now, it will ask for following credentials:

Client ID: Copy and paste from credentials.json

Client Secret: Copy and paste from credentials.json

Refresh Token: If you have previously generated a refresh token authenticated to your account, then enter it, otherwise leave blank. If you don’t have refresh token, script outputs a URL on the terminal script, open that url in a web browser and tap on allow. Copy the code and paste in the terminal.

Root Folder: Gdrive folder url/id from your account which you want to set as root folder. You can leave it blank and it takes root folder as default.

If everything went fine, all the required credentials have been set, read the next section on how to upload a file/folder.


After first run, the credentials are saved in config file. By default, the config file is ${HOME}/.googledrive.conf.

To change the default config file or use a different one temporarily, see -z / --config custom in Upload Script Custom Flags.

This is the format of a config file:

ACCOUNT_default_CLIENT_ID="client id"
ACCOUNT_default_CLIENT_SECRET="client secret"
ACCOUNT_default_REFRESH_TOKEN="refresh token"
SYNC_DEFAULT_ARGS="default args of gupload command for gsync"
ACCOUNT_default_ROOT_FOLDER_NAME="root folder name"
ACCOUNT_default_ROOT_FOLDER="root folder id"
ACCOUNT_default_ACCESS_TOKEN="access token"
ACCOUNT_default_ACCESS_TOKEN_EXPIRY="access token expiry"

where default is the name of the account.

You can use a config file in multiple machines, the values that are explicitly required are CLIENT_ID, CLIENT_SECRET and REFRESH_TOKEN.

If ROOT_FOLDER is not set, then it is asked if running in an interactive terminal, otherwise root is used.


SYNC_DEFAULT_ARGS is optional.

A pre-generated config file can be also used where interactive terminal access is not possible, like Continuous Integration, docker, jenkins, etc

Just have to print values to "${HOME}/.googledrive.conf", e.g:

printf "%s\n" '
ACCOUNT_default_CLIENT_ID="client id"
ACCOUNT_default_CLIENT_SECRET="client secret"
ACCOUNT_default_REFRESH_TOKEN="refresh token"
' >| "${HOME}/.googledrive.conf"

Note: If you have an old config, then nothing extra is needed, just need to run the script once and the default config will be automatically converted to the new format.


If you have followed the automatic method to install the script, then you can automatically update the script.

There are two methods:

Use the script itself to update the script.

gupload -u or gupload --update

This will update the script where it is installed.

If you use the this flag without actually installing the script,

e.g just by sh -u then it will install the script or update if already installed.

Run the installation script again.

Yes, just run the installation script again as we did in install section, and voila, it’s done.

Automatic updates

By default, script checks for update after 5 days. Use -t / –time flag of to modify the interval.

Note: Above methods always obey the values set by user in advanced installation, e.g if you have installed the script with different repo, say myrepo/gdrive-upload, then the update will be also fetched from the same repo.


If you have followed the automatic method to install the script, then you can automatically uninstall the script.

There are two methods:

Use the script itself to uninstall the script.

gupload -U or gupload --uninstall

This will remove the script related files and remove path change from shell file.

Run the installation script again with -U/–uninstall flag

curl --compressed -Ls | sh -s -- --uninstall

Yes, just run the installation script again with the flag and voila, it’s done.

Note: Above methods always obey the values set by user in advanced installation.

Read more: 

What is GEEK

Buddha Community

Bash shell script upload file to Google Drive on Ubuntu and Linux

I am Developer


Multiple File Upload in Laravel 7, 6

in this post, i will show you easy steps for multiple file upload in laravel 7, 6.

As well as how to validate file type, size before uploading to database in laravel.

Laravel 7/6 Multiple File Upload

You can easily upload multiple file with validation in laravel application using the following steps:

  1. Download Laravel Fresh New Setup
  2. Setup Database Credentials
  3. Generate Migration & Model For File
  4. Make Route For File uploading
  5. Create File Controller & Methods
  6. Create Multiple File Blade View
  7. Run Development Server

#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel

I am Developer


How to Delete Directories and Files in Linux using Command Line

In this remove or delete directories and files linux tutorial guide, you will learn how to remove empty directory and non empty directory linux using command line. And as well as how to remove/file files linux using command line.

If you work with Linux then you will need the following:

  • how to remove empty directory in linux,
  • how to remove non empty directory,
  • how to remove directory without confirmation linux
  • how to remove files with and without confirmation in linux.

So, this tutorial guide will show you you how to use the rmunlink, and rmdir commands to remove or delete files and directories in Linux with and without confirmation.

#how to delete directory in linux #how to remove non empty directory in linux #remove all files in a directory linux #linux delete all files in current directory #linux delete all files in a directory recursively #delete all files in a directory linux

Chet  Lubowitz

Chet Lubowitz


How to Install Microsoft Teams on Ubuntu 20.04

Microsoft Teams is a communication platform used for Chat, Calling, Meetings, and Collaboration. Generally, it is used by companies and individuals working on projects. However, Microsoft Teams is available for macOS, Windows, and Linux operating systems available now.

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. By default, Microsoft Teams package is not available in the Ubuntu default repository. However we will show you 2 methods to install Teams by downloading the Debian package from their official website, or by adding the Microsoft repository.

Install Microsoft Teams on Ubuntu 20.04

1./ Install Microsoft Teams using Debian installer file

01- First, navigate to teams app downloads page and grab the Debian binary installer. You can simply obtain the URL and pull the binary using wget;

$ wget${VERSION}_amd64.deb

#linux #ubuntu #install microsoft teams on ubuntu #install teams ubuntu #microsoft teams #teams #teams download ubuntu #teams install ubuntu #ubuntu install microsoft teams #uninstall teams ubuntu

I am Developer


Laravel 7 File Upload Example

Here i will show you how to upload files in laravel 7, 6, 5 version. And simply upload file like pdf, image, xlx, zip etc in laravel app.

Laravel 7 file upload example

Checkout this laravel 7 file upload example:-

#laravel file upload example #file upload in laravel 6 #file upload in laravel 7 #laravel file upload

Ray  Patel

Ray Patel


How to Run bash scripts Using Python?

If you are using Linux, then you would definitely love the shell commands.

And if you are working with Python, then you may have tried to automate things. That’s a way to save time. You may also have some bash scripts to automate things.

Python is handy to write scripts than bash. And managing Python scripts are easy compared to bash scripts. You will find it difficult to maintain the bash scripts once it’s growing.

But what if you already have bash scripts that you want to run using Python?

Is there any way to execute the bash commands and scripts in Python?

Yeah, Python has a built-in module called subprocess which is used to execute the commands and scripts inside Python scripts. Let’s see how to execute bash commands and scripts in Python scripts in detail.

#development #python #how to run bash scripts using python #shell script from python #bash script #shell=