gsutil
Manage Google Cloud Storage buckets and objects
TLDR
List all buckets in a project you are logged into
List the objects in a bucket
Download an object from a bucket
Upload an object to a bucket
Rename or move objects in a bucket
Create a new bucket in the project you are logged into
Delete a bucket and remove all the objects in it
SYNOPSIS
gsutil [global-options] command [args]
PARAMETERS
-D
Start debug log server on port 8080
-DD
Start debug log server; use with port argument
-e class[,class...]
Error trace for specified exception classes
-h HEADER:VALUE
Add HTTP header to requests
-m
Enable multi-threaded/multi-process for parallelism
-q
Quiet mode; suppress non-error console output
-r|-R
Recursive operation on directories
-s
Single-threaded execution (disables -m)
-u
Skip loading user config file
-v
Verbose mode; enable logging
--
Pass subsequent args to subcommand literally
--config-file FILE
Use alternate boto config file
--debug_gcs
Debug GCS requests
--no_crc32c
Disable CRC32C checksum validation
--parallel_composite_upload_threshold N
Threshold for parallel uploads (MB)
DESCRIPTION
gsutil is a Python-based command-line interface for interacting with Google Cloud Storage (GCS). It enables efficient management of buckets and objects, supporting operations like upload, download, copy, delete, and listing. Key features include parallel multi-threaded transfers (-m flag), ACL management, versioning, lifecycle rules, and resumable transfers for large files. gsutil mimics Unix utilities such as cp, mv, rm, and rsync, making it intuitive for Linux users.
Authentication uses OAuth 2.0 via gcloud auth or service account keys. It's installed via the Google Cloud SDK and configured through .boto or .boto2 files for advanced settings like encryption or proxies. Ideal for scripting, CI/CD pipelines, and data workflows, gsutil handles terabyte-scale transfers reliably. Use gsutil help for subcommand details; supports wildcards, ranges, and conditions for precise control.
CAVEATS
Requires Google Cloud SDK and authentication (gcloud auth login). Not installed by default on Linux. Large-scale use needs quota checks and IAM permissions. Debug flags (-D/-DD) expose tokens—use cautiously.
COMMON SUBCOMMANDS
cp: Copy objects.
ls: List buckets/objects.
mb: Make bucket.
rb: Remove bucket.
rm: Delete objects.
rsync: Sync directories.
du: Disk usage.
iam: Manage ACLs.
AUTHENTICATION
Run gcloud auth application-default login or use service account key: gcloud auth activate-service-account --key-file=KEY.json.
HISTORY
Developed by Google in 2009 as part of App Engine tools. Evolved with GCS launch (2010); integrated into Cloud SDK (2013). Python 3 support added in v4.0+; actively maintained for gcloud ecosystem.


