System management
# get project id
gcloud config get-value project
# set environmental vars
PROJECT_ID=`gcloud config get-value project`
BUCKET=mariocodes-personal-bucket
Buckets and objects operations
List, download and sync buckets. Upload files
# gsutil modificators
# -m multithread
# list buckets and objects in your bucket
gsutil ls
gsutil ls gs://${BUCKET}
# check storage classes
gsutil ls -Lr gs://${BUCKET} | more
# download the whole bucket
gsutil -m cp -R gs://${BUCKET} .
# sync local folder with bucket content
gsutil -m rsync -d -r local-folder gs://${BUCKET}
# use it with the whole root local folder
# -d delete files on target if they're missing on local
# -r recursive
# upload a file with nearline storage.
gsutil cp -s nearline thisanearlinefile gs://${BUCKET}
For more info on file storage classes check here
Modify objects
# make all objects in a folder public
gsutil -m acl set -R -a public-read gs://${BUCKET}/folder
# to confirm they're public go to
# http://storage.googleapis.com/<your-bucket-name>/folder/old.txt on a web-browser
Create and delete buckets
# Create a bucket and a multi-regional class store
gsutil mb -c multi_regional gs://${BUCKET}
# delete bucket with object
gsutil rm -rf gs://${BUCKET}
# delete an empty bucket
gsutil rb gs://${BUCKET}