← 返回命令列表

Linux command

gsutil 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

List buckets

gsutil ls

List bucket contents

gsutil ls gs://[bucket-name]

Copy file to bucket

gsutil cp [file.txt] gs://[bucket]/

Copy bucket to local

gsutil cp gs://[bucket]/[file] [./]

Sync directory to bucket

gsutil rsync -r [local_dir] gs://[bucket]/[path]

Make object public

gsutil acl ch -u AllUsers:R gs://[bucket]/[file]

Remove object

gsutil rm gs://[bucket]/[file]

说明

gsutil is a command-line tool for interacting with Google Cloud Storage (GCS). It provides commands for creating and deleting buckets, uploading and downloading objects, synchronizing local directories with remote bucket paths, and managing access control lists (ACLs) and bucket policies. Objects are referenced using the `gs://bucket/path` URI scheme. For large-scale operations, the `-m` flag enables parallel, multi-threaded execution of commands like `cp`, `mv`, `rm`, and `rsync`, significantly improving throughput when working with many files or large datasets. Transfers are resumable by default -- interrupted uploads and downloads can be retried without starting over. gsutil also supports server-side features such as object versioning, lifecycle management, and cross-bucket replication, and it authenticates through the Google Cloud SDK's credential system.

参数

ls
List buckets or objects.
cp
Copy files/objects.
mv
Move files/objects.
rm
Remove objects.
rsync
Synchronize directories.
mb
Make bucket.
rb
Remove bucket.
acl
Manage access control.
-m
Parallel operations.
-r
Recursive operation.
-n
Dry run (no changes).

FAQ

What is the gsutil command used for?

gsutil is a command-line tool for interacting with Google Cloud Storage (GCS). It provides commands for creating and deleting buckets, uploading and downloading objects, synchronizing local directories with remote bucket paths, and managing access control lists (ACLs) and bucket policies. Objects are referenced using the `gs://bucket/path` URI scheme. For large-scale operations, the `-m` flag enables parallel, multi-threaded execution of commands like `cp`, `mv`, `rm`, and `rsync`, significantly improving throughput when working with many files or large datasets. Transfers are resumable by default -- interrupted uploads and downloads can be retried without starting over. gsutil also supports server-side features such as object versioning, lifecycle management, and cross-bucket replication, and it authenticates through the Google Cloud SDK's credential system.

How do I run a basic gsutil example?

Run `gsutil ls` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does ls do in gsutil?

List buckets or objects.