Google Cloud Storage(GCS) using CLI
Till now we did GCS lab using UI, Let's use CLI to create a bucket and Play with it accordingly
Shall we proceed!!!
Step 1 :- In the top right corner of the console, click on the CMD icon to open the Cloud Shell.
Step 2 :- Type out the command as follows.
gsutil --version
if you get popup like this click on Authorize
Step 3 :- Here's an example of how to create a bucket and give it a unique name for your bucket.
gsutil mb gs://[bucket-name]
mb - Make buckets
gs - Google storage
Your bucket will be created.
Step 4 :- If you want to list your bucket.
gsutil ls
Step 5 :- create a number of text files according to your wish.
touch command to create a text file.
touch 1.txt 2.txt
**ls **command to list files.
ls
Step 6 :- we will put text file into our bucket.
**cp **- we use **cp **to upload and download files.
gsutil cp 1.txt gs://[bucket-name]
Click on your bucket and check your files should be there.
Step 7 :- To list your files in your bucket.
gsutil ls gs://[bucket-name]
Step 8 :- If you want to download files from your bucket to your directory.
lets remove files from our directory.
**rm **- to remove files.
And **ls ** to list your files
gsutil cp gs://[bucket-name]/1.txt .
Now when you write this above command you will get below result.
When you do ls, you will get your files back.
Step 9 :- You can see all the ACL permissions on a given object.
**acl **- access control lists (it basically says who has the object or bucket access also the level of access like owner, admin, viewer role)
gsutil acl get gs://[bucket-name]/1.txt
Step 10 :- we are going to reader access to our object.
**ch ** - subcommands
-u - what kind of user role you want give.
gsutil acl ch -u Allusers:R gs://[bucket-name]/1.txt
Your object will become publicly accessible after you refresh your browser.
That's it, for now, we will continue further in next blog.
Hope you liked it. Will see you on the next topic ๐
##Next Topic
https://bvakash.hashnode.dev/google-compute-enginegce
Subscribe to my newsletter
Read articles from B V AKASH directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
B V AKASH
B V AKASH
I design, architect, and maintain hybrid cloud environments.