gcloud storage
(General Availability) is the recommended command-line tool for
interacting with Cloud Storage. This page helps you transition from gsutil
to gcloud storage
by describing the major differences and command mappings
between the two tools. For a detailed description of the gcloud storage
tool,
see the gcloud storage
reference documentation.
To learn how to install and get started using the Google Cloud CLI, see Install the Google Cloud CLI.
Behavioral differences
The following sections describe the behavioral differences between gsutil
and
gcloud storage
.
Parallel invocations
gcloud storage
doesn't support running multiple instances of the CLI from
different terminals simultaneously.
Parallel processing
gcloud storage
supports parallel processing.
Wildcard handling
gcloud storage
simplifies multiple asterisks. If you use three or more
asterisks in a row (***
), it treats them as a single asterisk (*
).
Handling of hierarchical namespace buckets
gcloud storage
can be used to create and manage buckets with
hierarchical namespace enabled.
Output formatting
The gcloud storage
and gsutil
commands format their output differently.
While minor changes like logging format might not affect you, more significant
differences in error messages and data listings can break automated scripts.
If you have scripts that rely on parsing gsutil
command output, you should
review and update them for the gcloud storage
format before transitioning
them.
gcloud command equivalents
All existing gsutil
commands have equivalent commands in gcloud storage
,
with a few exceptions. You can get a full list of the
gcloud storage
commands by visiting the reference documentation
or by running gcloud storage --help
. The following table briefly outlines the
changes from popular gsutil
commands.
Operation | gsutil command | gcloud storage command |
---|---|---|
Manage Access Control Lists (ACLs) |
gsutil acl get gsutil acl set gsutil acl ch |
gcloud storage RESOURCE describe --format="multi(acl:format=json)" gcloud storage RESOURCE update --acl-file=ACL_FILE_PATH gcloud storage RESOURCE update --add-acl-grant=GRANT gcloud storage RESOURCE update --remove-acl-grant=GRANT |
Operation | gsutil command | gcloud storage command |
---|---|---|
Concatenate objects and display object content |
gsutil cat |
gcloud storage cat |
Operation | gsutil command | gcloud storage command |
---|---|---|
Concatenate objects by combining them into a new object |
gsutil compose |
gcloud storage objects compose |
NotesTo apply preconditions ingcloud storage objects compose , use
specific flags, such as --if-generation-match or
--if-metageneration-match .
|
Operation | gsutil command | gcloud storage command |
---|---|---|
Copy objects and other resources |
gsutil cp |
gcloud storage cp |
NotesSimulated folders
created using the Google Cloud console are recognized as
0-byte placeholder objects. When handling errors, When downloading an object, |
Operation | gsutil command | gcloud storage command |
---|---|---|
Display the total disk space used by objects |
gsutil du |
gcloud storage du |
Operation | gsutil command | gcloud storage command |
---|---|---|
Calculate file hashes |
gsutil hash |
gcloud storage hash |
Notes
|
Operation | gsutil command | gcloud storage command |
---|---|---|
Manage bucket labels |
gsutil label get gsutil label set gsutil label ch |
gcloud storage buckets describe gcloud storage buckets update gcloud storage buckets update |
NotesThe combination of adding, updating, and removing labels in a single
|
Operation | gsutil command | gcloud storage command |
---|---|---|
List buckets, objects, and folders |
gsutil ls |
gcloud storage ls |
NotesWhen a wildcard is used to list objects in a project, When using
|
Operation | gsutil command | gcloud storage command |
---|---|---|
Move and rename objects or directories |
gsutil mv |
gcloud storage mv |
Operation | gsutil command | gcloud storage command |
---|---|---|
Rewrite objects in place |
gsutil rewrite |
gcloud storage objects update |
NotesIf an
|
Operation | gsutil command | gcloud storage command |
---|---|---|
Remove objects or buckets |
gsutil rm |
gcloud storage rm |
NotesThe There's a known issue where |
Operation | gsutil command | gcloud storage command |
---|---|---|
Synchronize the contents of two buckets or directories |
gsutil rsync |
gcloud storage rsync |
NotesBy default,
|
Operation | gsutil command | gcloud storage command |
---|---|---|
Set metadata on uploaded objects |
gsutil setmeta |
gcloud storage objects update |
Notes
In |
Operation | gsutil command | gcloud storage command |
---|---|---|
Display object status |
gsutil stat |
gcloud storage objects list --stat --fetch-encrypted-object-hashes |
NotesThe output format of |