gsutil is Google Storage CLI tool. Equivalent to aws s3 but for the Google Cloud Platform, it allows you to access Google Cloud Storage from the command line. Beyond moving files and managing buckets, gsutil is a powerful file management (rsync) and file publication tool (signed urls).

Please find below a shortlist of the most important and frequent commands and their relative syntax.

This is a work in progress that will be updated within the next few days.

Gsutil cheatsheet

gsutil is Google Cloud storage CLI. More info on

Definitions
  • GCP: Google Cloud Platform
Install

To get started with gsutil you need python (at least 2.7) and to install the Google Cloud SDK. See https://cloud.google.com/sdk/docs/ to download the right package for your environment.

General Commands
  • gsutil ls: lists all your buckets
  • gsutil help <topic>: help on the topic
Buckets
  • gsutil mb gs://<bucket_name>: creates the gs://bucket_name1.

  • gsutil rb gs://<bucket_name>: deletes the bucket.

Files
  • gsutil cp <filename> gs://<bucket_name>/: copies the local filename into the bucket ****.

  • gsutil cp <filename> gs://<bucket_name>/directory/: copies the local filename into the directory ****2.

  • gsutil mv <src_filename> gs://<bucket_name>/directory/<tgt_filename>: moves the local src_filename to the directory and renames it as tgt_filename

  • gsutil rm gs://<bucket_name>/file_or_dir: deletes the file_or_dir object.

Folder
  • gsutil cp <filename> gs://<bucket_name>/: copies the local filename into the bucket ****.
Footnotes
  • 1: The bucket name has to be unique across GCP.
  • 2: Note the trailing ‘/’ slash after < directory > to tell gsutil that the target is a directory and not a file