Google Cloud command line for GCS(Google cloud storage)

Google cloud platform command line## basic commands for managing buckets##

if you are new to google cloud, go to their website and create your own account.

Here

Although AWS is the leader in the cloud plaform, more companies started to use google cloud as well.

As you know in aws, we can store objects, static files in S3 buckets . There is a same exact concept in google cloud.

GCS ( Google cloud storage )

With GCS;



we can create buckets
Enable versioning
( If versioning enabled, eventhough we delete an object from a bucket, it will not be deleted and can preview with a historical google-number)
Can add,download files from/to buckets
copy files from one bucket to another



Another functionality in in GCP (google cloud flatform) is its own web browser command line terminal. Once you are in the console , you can open this terminal in your browser via clicking the topmost icon bar wher you see the symbol of a terminal.

Here we are learning some simple and common gsutil commands to interact with our google cloud storage buckets.

gsutil is a special commandline util designed for interacting with google buckets.

So, once you have enabled command line and you are in the terminal;

here we start with simple and powerfull google command line.


To list out all buckets.

gsutil ls


gs://bucket1

gs://bucket2

gs://bucket3

Which will list out all buckets associated with the current project.


To see configuration the project

gcloud config list


Which will list out all associated information related to the current shell. It will show the project name, account owner and so on

3. To see bucket contents

gsutil ls gs://bucket1/

It will list out all bucket contents inside of bucket1


To see a flat file list inside of a bucket


gsutil ls gs://bucket1/**

It will list out all files under bucket1 and its subfolders

5. create a bucket

First we can check what the command "gsutil mb" do

gsutil mb --hlp

will show you all available options while creating a google bucket.

then

gsutil mb -l northamerica-northeast gs://bucket5

-l ---> will stands for location name

Here you get available options for locations

https://cloud.google.com/storage/docs/bucket-locations


To check versioning enabled or not

gsutil versioning get gs://bucket2


gs://bucket2 : suspended

As you see, versioining is not enabled in this bucket, if yuu need to enable versioning

gsutil versioing set on gs://bucket2


Copying files from one bucket to another


gsutil cp gs://bucket1/** gs://bucket2/

will continue------------------------Amigos

Top News