GSUTIL Command-line utility for Google Cloud Storage
Create Bucket (Including Storage Class, Location)
gsutil mb -c [storage class] -l [location] gs://bucket-name
gsutil rm -r gs://bucket-name
gsutil -m cp -r . gs://bucket-nameTurn on versioning on bucket (get details of versioning enable or not)
gsutil versioning get gs://bucket-name
Set versioning offgsutil versioning set off gs://bucket-name
Enable the versioninggsutil versioning set on gs://bucket-name
List all version of a filegsutil ls -a gs://bucket-name
Long listing format generation and meta-generationgsutil ls -al gs://bucket-name
Changes the storage class of a object in a bucket gsutil rewrite -s NEARLINE gs://bucket-name/*
Change the storage class of multiple objects (Multi-Threading Parallel) gsutil -m rewrite -s NEARLINE gs://bucket-name/*
Access Control List (ACL) on objects (Public access to the general public)gsutil acl ch -u AllUsers:R gs://bucket-name/filename
ACL Remove the public access to the general public gsutil acl ch -d AllUsres gs://bucket-name/filename
Removed the bucket and inside it's objectsgsutil -m rm -r gs://bucket-name
Removed only objects inside a bucketgsutil -m rm -r gs://bucket-name/*
Check the storage space of a bucket gsutil du -h gs://bucket-name
gsutil help for commands gsutil [command] help
Rsync within folders in bucket gsutil rsync [source-folder] [target-folder]
Rsync from local folder to GCS bucket folder gsutil rsync [local-folder] gs://bucket-name
Rsync deleted the contents in the target when deleted from the source gsutil -m rsync -r -d [local-folder] gs://bucket-name/
Signed URL (Give access to a object for the specific time period)We need to create a service account for that and use the same json key for Sign URL -
gsutil signurl -d 10m -m GET [path-to-the-json-key] gs://bucket-name