LinuxCommandLibrary

gsutil

The gsutil CLI lets you access Google Cloud Storage from the command line.

TLDR

List all buckets in a project you are logged into

$ gsutil ls
copy


List the objects in a bucket
$ gsutil ls -r 'gs://[bucket_name]/[prefix]**'
copy


Download an object from a bucket
$ gsutil cp gs://[bucket_name]/[object_name] [path/to/save_location]
copy


Upload an object to a bucket
$ gsutil cp [object_location] gs://[destination_bucket_name]/
copy


Rename or move objects in a bucket
$ gsutil mv gs://[bucket_name]/[old_object_name] gs://[bucket_name]/[new_object_name]
copy


Create a new bucket in the project you are logged into
$ gsutil mb gs://[bucket_name]
copy


Delete a bucket and remove all the objects in it
$ gsutil rm -r gs://[bucket_name]
copy

Copied to clipboard