iPax.dev

No nonsense quick references

Google Storage Cheet Sheet

A list of gsutil commands to manage your Google Storage buckets.

List buckets

gsutil ls

List bucket content

gsutil ls gs://bucket-name
gsutil ls gs://bucket-name/ads # Lists a sub folder
gsutil ls gs://bucket-name/*.png # Lists files with extension png

gsutil ls -l gs://bucket-name # List with more object information
gsutil ls -L gs://bucket-name/object-name # Shows object details

Show bucket metadata

gsutil ls -L -b gs://bucket-name

External documentation: ls command on Google Cloud docs Opens in new window

Upload object

gsutil cp filename gs://bucket-name/
gsutil cp *.pdf gs://bucket-name/ # Upload all files with extension pdf
gsutil cp picture.jpg gs://bucket-name/pictures # Upload one file to a storage bucket folder

Download object

gsutil cp gs://bucket-name/object-name location
gsutil cp gs://bucket-name/*.jpg /local-folder # Downloads all .jpg files

Copy object

gsutil cp gs://from-bucket/object-name gs://to-bucket/object-name

External documentation: cp command on Google Cloud docs Opens in new window

Rename object

gsutil mv gs://bucket-name/object-name gs://bucket-name/new-object-name

Move object

gsutil mv gs://bucket-name/object-name gs://other-bucket/object-name

External documentation: mv command on Google Cloud docs Opens in new window

Delete object

gsutil rm gs://bucket-name/object-name
gsutil -m rm gs://bucket-name/*.txt # deletes all .txt files in the bucket
gsutil -m rm gs://bucket-name/** # delete all objects in bucket

Delete bucket

gsutil rm -r gs://bucket-name # remove the bucket and its content

External documentation: rm command on Google Cloud docs Opens in new window

Make object public

gsutil acl ch -u AllUsers:R gs://bucket-name/object-name

Make bucket public

gsutil iam ch allUsers:objectViewer gs://bucket-name