Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
Discover object storage with the gcloud toolThis page shows you how to perform basic tasks in Cloud Storage using the gcloud command-line tool.
Costs that you incur in Cloud Storage are based on the resources you use. This quickstart typically uses less than $0.01 USD worth of Cloud Storage resources.
Before you beginInstall the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
Create or select a Google Cloud project.
Roles required to select or create a project
roles/resourcemanager.projectCreator
), which contains the resourcemanager.projects.create
permission. Learn how to grant roles.Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace PROJECT_ID
with a name for the Google Cloud project you are creating.
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace PROJECT_ID
with your Google Cloud project name.
Verify that billing is enabled for your Google Cloud project.
Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/storage.admin
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
Replace the following:
PROJECT_ID
: Your project ID.USER_IDENTIFIER
: The identifier for your user account. For example, myemail@example.com
.ROLE
: The IAM role that you grant to your user account.Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloud init
Create or select a Google Cloud project.
Roles required to select or create a project
roles/resourcemanager.projectCreator
), which contains the resourcemanager.projects.create
permission. Learn how to grant roles.Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace PROJECT_ID
with a name for the Google Cloud project you are creating.
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace PROJECT_ID
with your Google Cloud project name.
Verify that billing is enabled for your Google Cloud project.
Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/storage.admin
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
Replace the following:
PROJECT_ID
: Your project ID.USER_IDENTIFIER
: The identifier for your user account. For example, myemail@example.com
.ROLE
: The IAM role that you grant to your user account.gcloud init
and follow the instructions. Create a bucket
Buckets are the basic containers that hold your data in Cloud Storage.
To create a bucket:
Use the gcloud storage buckets create
command and a unique name to create a bucket:
gcloud storage buckets create gs://my-awesome-bucket/ --uniform-bucket-level-access
This uses a bucket named "my-awesome-bucket." You must choose your own, globally-unique, bucket name.
See bucket naming requirements.-
), underscores (_
), and dots (.
). Spaces are not allowed. Names containing dots require verification.If successful, the command returns:
Creating gs://my-awesome-bucket/...
You've just created a bucket where you can store your data!
Note: If the bucket name you chose is already in use, either by you or someone else, the command returns:Creating gs://my-awesome-bucket/... ServiceException: 409 Bucket my-awesome-bucket already exists.
Try again with a different bucket name.
Upload an object into your bucketRight-click the image above and save it somewhere on your computer, such as on the desktop.
Note: If you are using Cloud Shell or a Compute Engine instance, download the image using the following command:wget https://cloud.google.com/storage/images/kitten.png
Use the gcloud storage cp
command to copy the image from the location where you saved it to the bucket you created:
gcloud storage cp Desktop/kitten.png gs://my-awesome-bucket
If successful, the command returns:
Copying file://Desktop/kitten.png [Content-Type=image/png]... Uploading gs://my-awesome-bucket/kitten.png: 0 B/164.3 KiB Uploading gs://my-awesome-bucket/kitten.png: 164.3 KiB/164.3 KiB
You've just stored an object in your bucket.
Use the gcloud storage cp
command to download the image you stored in your bucket to somewhere on your computer, such as the desktop:
gcloud storage cp gs://my-awesome-bucket/kitten.png Desktop/kitten2.png
If successful, the command returns:
Copying gs://my-awesome-bucket/kitten.png... Downloading file://Desktop/kitten2.png: 0 B/164.3 KiB Downloading file://Desktop/kitten2.png: 164.3 KiB/164.3 KiB
You've just downloaded something from your bucket.
Use the gcloud storage cp
command to create a folder and copy the image into it:
gcloud storage cp gs://my-awesome-bucket/kitten.png gs://my-awesome-bucket/just-a-folder/kitten3.pngNote: Folders in Cloud Storage have limitations compared to local filesystems, but many of the same operations are supported.
If successful, the command returns:
Copying gs://my-awesome-bucket/kitten.png [Content-Type=image/png]... Copying ...my-awesome-bucket/just-a-folder/kitten3.png: 164.3 KiB/164.3 KiB
You've just copied your image into a new folder in your bucket.
Use the gcloud storage ls
command to list the contents at the top level of your bucket:
gcloud storage ls gs://my-awesome-bucket
If successful, the command returns a message similar to:
gs://my-awesome-bucket/kitten.png gs://my-awesome-bucket/just-a-folder/
You've just seen the contents at the top level of your bucket.
Use the gcloud storage ls
command, with the --long
flag to get some details about a one of your images:
gcloud storage ls gs://my-awesome-bucket/kitten.png --long
If successful, the command returns a message similar to:
2638 2016-02-26T23:05:14Z gs://my-awesome-bucket/kitten.png TOTAL: 1 objects, 168243.2 bytes (164.3 KiB)
You've just obtained information about the image's size and date of creation.
Use the gcloud storage buckets add-iam-policy-binding
command to grant all users permission to read the images stored in your bucket:
gcloud storage buckets add-iam-policy-binding gs://my-awesome-bucket --member=allUsers --role=roles/storage.objectViewer
The command is successful if your response contains the following:
bindings:
- members:
- allUsers
role: roles/storage.objectViewer
Now anyone can get your images.
To remove this access, use the command:
gcloud storage buckets remove-iam-policy-binding gs://my-awesome-bucket --member=allUsers --role=roles/storage.objectViewer
The command is successful if no error is returned.
You have removed public access to the images in your bucket.
Use the gcloud storage buckets add-iam-policy-binding
command to give a specific email address permission to add objects to your bucket:
gcloud storage buckets add-iam-policy-binding gs://my-awesome-bucket --member=user:jeffersonloveshiking@gmail.com --role=roles/storage.objectCreator
The command is successful if your response contains the following:
bindings:
- members:
- user:jeffersonloveshiking@gmail.com
role: roles/storage.objectCreator
Now someone else can add items to your bucket.
To remove this permission, use the command:
gcloud storage buckets remove-iam-policy-binding gs://my-awesome-bucket --member=user:jeffersonloveshiking@gmail.com --role=roles/storage.objectCreator
The command is successful if no error is returned.
You have removed the user's access to this bucket.
Use the gcloud storage rm
command to delete one of your images:
gcloud storage rm gs://my-awesome-bucket/kitten.png
If successful, the command returns:
Removing gs://my-awesome-bucket/kitten.png...
This copy of the image is no longer stored on Cloud Storage (though the copy you made in the folder just-a-folder/
still exists).
To avoid incurring charges to your Google Cloud account for the resources used on this page, delete the Google Cloud project with the resources.
Use the gcloud storage rm
command with the --recursive
flag to delete the bucket and anything inside of it:
gcloud storage rm gs://my-awesome-bucket --recursive
If successful, the command returns a message similar to:
Removing gs://my-awesome-bucket/just-a-folder/cloud-storage.logo.png#1456530077282000... Removing gs://my-awesome-bucket/...
Your bucket and its contents are deleted.
buckets create
), copy (cp
), list (ls
), add access (buckets add-iam-policy-binding
), and remove (rm
).Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5