Creating and removing Google Storage Buckets using the gsutil tools

Creating and removing Google Storage Buckets. The gsutil tool can create Google Storage Buckets with ease after you have configured the Google gsutil client. Examples of using the gsutil to create and remove Google Storage Buckets.  Base Syntax:

gsutil mb [-c class] [-l location] [-p proj_id] uri
Example:
  • we will create a bucket using the default options.
[root@aodba /]# gsutil mb gs://test-bkt-aodba
Creating gs://test-bkt-aodba/...
List the created bucket:
[root@aodba /]# gsutil ls
gs://test-bkt-aodba/
Create multiple buckets with the same gsutil comand:
[root@aodba /]# gsutil mb gs://bkt1-aodba gs://bkt2-aodba
Creating gs://bkt1-aodba/...
Creating gs://bkt2-aodba/...

[root@aodba /]# gsutil ls |grep aodba
gs://bkt1-aodba/
gs://bkt2-aodba/
Note:
  • buckets name must be unique at a global level and not only to your bucket naming list
Remove a Google Storage Bucket: Base Syntax:
gsutil rb [-f] url
Example: 
  • we will remove the bucket we created in the previous step.
[root@aodba /]# gsutil rb gs://test-bkt-aodba
Removing gs://test-bkt-aodba/...
Remove multiple buckets:
[root@aodba tmp]# gsutil rb gs://bkt1-aodba/ gs://bkt2-aodba/
Removing gs://bkt1-aodba/...
Removing gs://bkt2-aodba/...
Note:
  • the bucket needs to be empty before running the rb command, so remove or move any contents of the bucket before dropping the bucket.
I find gsutil quite easy to use and very similar to Linux  own commands. In future articles we will see more advanced topics on how we can use gsutil tool.