Google Cloud GCloud Cheat Sheet
📋 Last Updated: June 2026. Updated with gcloud storage commands (replacing deprecated gsutil), Spot VMs (replacing preemptible), Cloud Run, Artifact Registry, and Deployment Manager deprecation notice.
Google Cloud Config
| PURPOSE |
COMMAND |
| Initialize gcloud CLI |
gcloud init |
| Display version and components |
gcloud version |
| List config properties |
gcloud config list |
| Show project info |
gcloud compute project-info describe |
| Switch project |
gcloud config set project <project-id> |
| Set the active account |
gcloud config set account <ACCOUNT> |
| Set default region |
gcloud config set compute/region us-west1 |
| Set default zone |
gcloud config set compute/zone us-west1-b |
| List configurations |
gcloud config configurations list |
| Create configuration |
gcloud config configurations create <config-name> |
| Activate configuration |
gcloud config configurations activate <config-name> |
| Get property value |
gcloud config get compute/region |
Google Cloud IAM
| PURPOSE |
COMMAND |
| Get project IAM policy |
gcloud projects get-iam-policy <project-id> |
| Add IAM policy binding |
gcloud projects add-iam-policy-binding <project-id> --member=<member> --role=<role> |
| Copy roles across org and projects |
gcloud iam roles copy --source=<role> --destination=<role> --dest-project=<project-id> |
| List grantable roles |
gcloud iam list-grantable-roles <resource> |
| Create custom role |
gcloud iam roles create <role-id> --project=<project-id> --permissions=<permissions> |
| Create service account |
gcloud iam service-accounts create <name> --display-name=<display-name> |
| List service accounts |
gcloud iam service-accounts list |
| List service account keys |
gcloud iam service-accounts keys list --iam-account=<sa-email> |
Google Cloud Auth
| PURPOSE |
COMMAND |
| Authorize with user credentials |
gcloud auth login |
| Display a list of credentialed accounts |
gcloud auth list |
| Authenticate with service account |
gcloud auth activate-service-account --key-file=<key-file> |
| Auth to Container/Artifact Registry |
gcloud auth configure-docker <region>-docker.pkg.dev |
| Print access token for active account |
gcloud auth print-access-token |
| Set up Application Default Credentials |
gcloud auth application-default login |
| Revoke credentials |
gcloud auth revoke <account> |
Google Cloud Storage
⚠️ Note: gsutil is no longer the recommended CLI for Cloud Storage. Google recommends using gcloud storage commands instead, which are faster by default and support newer features like soft delete and managed folders.
| PURPOSE |
COMMAND (gcloud storage – Recommended) |
LEGACY COMMAND (gsutil) |
| List all buckets |
gcloud storage ls |
gsutil ls |
| List bucket contents |
gcloud storage ls gs://<bucket-name> |
gsutil ls -lh gs://<bucket-name> |
| Create bucket |
gcloud storage buckets create gs://<bucket-name> |
gsutil mb gs://<bucket-name> |
| Download file |
gcloud storage cp gs://<bucket>/<path>/file.txt . |
gsutil cp gs://<bucket>/<path>/file.txt . |
| Upload file |
gcloud storage cp <file> gs://<bucket>/<dir>/ |
gsutil cp <file> gs://<bucket>/<dir>/ |
| Delete file |
gcloud storage rm gs://<bucket>/<filepath> |
gsutil rm gs://<bucket>/<filepath> |
| Move/rename file |
gcloud storage mv <src> gs://<bucket>/<dest> |
gsutil mv <src> gs://<bucket>/<dest> |
| Copy folder recursively |
gcloud storage cp -r ./conf gs://<bucket>/ |
gsutil cp -r ./conf gs://<bucket>/ |
| Show disk usage |
gcloud storage du gs://<bucket>/<dir> |
gsutil du -h gs://<bucket>/<dir> |
| Sync directories |
gcloud storage rsync ./local gs://<bucket>/<dir> |
gsutil rsync ./local gs://<bucket>/<dir> |
| Generate signed URL |
gcloud storage sign-url gs://<bucket>/<object> --duration=20m |
gsutil signurl -d 20m <key-file> gs://<bucket>/<object> |
| Describe bucket |
gcloud storage buckets describe gs://<bucket-name> |
gsutil ls -L -b gs://<bucket-name> |
Google Kubernetes Engine (GKE)
| PURPOSE |
COMMAND |
| Create Standard cluster |
gcloud container clusters create <cluster-name> --num-nodes=3 --zone=<zone> |
| Create Autopilot cluster |
gcloud container clusters create-auto <cluster-name> --region=<region> |
| List all container clusters |
gcloud container clusters list |
| Get cluster credentials (set kubectl context) |
gcloud container clusters get-credentials <cluster-name> --zone=<zone> |
| Set default cluster |
gcloud config set container/cluster <cluster-name> |
| Resize cluster node pool |
gcloud container clusters resize <cluster-name> --num-nodes=<count> --node-pool=<pool> |
| Update cluster (enable autoscaling) |
gcloud container clusters update <cluster-name> --enable-autoscaling --min-nodes=1 --max-nodes=5 |
| Delete cluster |
gcloud container clusters delete <cluster-name> |
| List node pools |
gcloud container node-pools list --cluster=<cluster-name> |
| Create node pool with Spot VMs |
gcloud container node-pools create <pool-name> --cluster=<cluster> --spot |
Google Cloud Compute Engine
| PURPOSE |
COMMAND |
| List all instances |
gcloud compute instances list |
| List instance templates |
gcloud compute instance-templates list |
| Show instance info |
gcloud compute instances describe <instance-name> --zone=<zone> |
| Stop an instance |
gcloud compute instances stop <instance-name> --zone=<zone> |
| Start an instance |
gcloud compute instances start <instance-name> --zone=<zone> |
| Create an instance |
gcloud compute instances create <vm-name> --image-family=<family> --image-project=<project> --zone=<zone> --machine-type=e2-micro |
| Create a Spot VM |
gcloud compute instances create <vm-name> --provisioning-model=SPOT --instance-termination-action=STOP |
| Create preemptible instance (legacy) |
gcloud compute instances create <vm-name> --preemptible |
| SSH to instance |
gcloud compute ssh <instance-name> --zone=<zone> |
| List available images |
gcloud compute images list |
| List available zones |
gcloud compute zones list |
| List machine types |
gcloud compute machine-types list --filter="zone:<zone>" |
| Create snapshot |
gcloud compute disks snapshot <disk-name> --zone=<zone> |
| List snapshots |
gcloud compute snapshots list |
💡 Spot VMs vs Preemptible VMs: Spot VMs are the latest version of preemptible VMs and are recommended. Key differences: Spot VMs have no 24-hour maximum runtime limit, and pricing is the same. Use --provisioning-model=SPOT instead of --preemptible.
Cloud Run & Cloud Functions
| PURPOSE |
COMMAND |
| Deploy a Cloud Run service |
gcloud run deploy <service-name> --image=<image> --region=<region> |
| List Cloud Run services |
gcloud run services list |
| Describe Cloud Run service |
gcloud run services describe <service-name> --region=<region> |
| Delete Cloud Run service |
gcloud run services delete <service-name> --region=<region> |
| Update traffic splitting |
gcloud run services update-traffic <service> --to-revisions=<rev>=100 |
| Deploy Cloud Run function |
gcloud functions deploy <function-name> --runtime=<runtime> --trigger-http --region=<region> |
| List Cloud Functions |
gcloud functions list |
| View function logs |
gcloud functions logs read <function-name> |
| Delete Cloud Function |
gcloud functions delete <function-name> --region=<region> |
Virtual Private Cloud (VPC) Network
| PURPOSE |
COMMAND |
| List all networks |
gcloud compute networks list |
| Detail of one network |
gcloud compute networks describe <network-name> --format=json |
| Create network |
gcloud compute networks create <network-name> --subnet-mode=custom |
| Create subnet |
gcloud compute networks subnets create <subnet-name> --network=<network> --range=10.0.0.0/24 --region=<region> |
| List all firewall rules |
gcloud compute firewall-rules list |
| List all forwarding rules |
gcloud compute forwarding-rules list |
| Describe one firewall rule |
gcloud compute firewall-rules describe <rule-name> |
| Create firewall rule |
gcloud compute firewall-rules create <rule-name> --network=default --allow=tcp:22 --source-ranges=0.0.0.0/0 |
| Update firewall rule |
gcloud compute firewall-rules update <rule-name> --allow=tcp:80,tcp:443 |
| Delete firewall rule |
gcloud compute firewall-rules delete <rule-name> |
Artifact Registry
| PURPOSE |
COMMAND |
| List repositories |
gcloud artifacts repositories list |
| Create Docker repository |
gcloud artifacts repositories create <repo> --repository-format=docker --location=<region> |
| List images in repository |
gcloud artifacts docker images list <region>-docker.pkg.dev/<project>/<repo> |
| Configure Docker authentication |
gcloud auth configure-docker <region>-docker.pkg.dev |
| Delete repository |
gcloud artifacts repositories delete <repo> --location=<region> |
App Engine
| PURPOSE |
COMMAND |
| Create App Engine app |
gcloud app create --region=<region> |
| Deploy application |
gcloud app deploy |
| List versions |
gcloud app versions list |
| Open app in browser |
gcloud app browse |
| View application logs |
gcloud app logs read |
Components
| PURPOSE |
COMMAND |
| List installed components |
gcloud components list |
| Update all components |
gcloud components update |
| Install a component |
gcloud components install <component-name> |
| Remove a component |
gcloud components remove <component-name> |
Deployment Manager
⚠️ DEPRECATED: Google Cloud Deployment Manager reached End of Support on December 31, 2025, and will be discontinued on March 31, 2026. Migrate to Infrastructure Manager (Terraform-based) or use Terraform directly.
| PURPOSE |
COMMAND |
| Create deployment |
gcloud deployment-manager deployments create <name> --config=<config.yaml> |
| Update deployment |
gcloud deployment-manager deployments update <name> --config=<config.yaml> |
| Delete deployment |
gcloud deployment-manager deployments delete <name> |
| List deployments |
gcloud deployment-manager deployments list |
Miscellaneous
| PURPOSE |
COMMAND |
| Display environment details |
gcloud info |
| List project logs |
gcloud logging logs list |
| Read log entries |
gcloud logging read "resource.type=gce_instance" --limit=10 |
| Decrypt with KMS |
gcloud kms decrypt --key=<key> --keyring=<ring> --location=<loc> --ciphertext-file=<in> --plaintext-file=<out> |
| List Cloud SQL instances |
gcloud sql instances list |
| Export Cloud SQL to SQL file |
gcloud sql export sql <instance> gs://<bucket>/<file>.sql --database=<db> |
| List Pub/Sub topics |
gcloud pubsub topics list |
| Publish message to topic |
gcloud pubsub topics publish <topic> --message="Hello" |
GCP Certification Exam Practice Questions
- Questions are collected from Internet and the answers are marked as per my knowledge and understanding (which might differ with yours).
- GCP services are updated everyday and both the answers and questions might be outdated soon, so research accordingly.
- GCP exam questions are not updated to keep up the pace with GCP updates, so even if the underlying feature has changed the question might not be updated
- Open to further feedback, discussion and correction.
- You have a development project with appropriate IAM roles defined. You are creating a production project and want to have the same IAM roles on the new project, using the fewest possible steps. What should you do?
- Use gcloud iam roles copy and specify the production project as the destination project.
- Use gcloud iam roles copy and specify your organization as the destination organization.
- In the Google Cloud Platform Console, use the ‘create role from role’ functionality.
- In the Google Cloud Platform Console, use the ‘create role’ functionality and select all applicable permissions.
- Your team is working on GKE cluster named dev. You have downloaded and installed the gcloud command line interface (CLI) and SDK. You want to avoid having to specify this GKE config with each CLI command when managing this cluster. What should you do?
- Set the dev cluster as the default cluster using the gcloud container update dev
- Set the dev cluster as the default cluster using the gcloud config set container/cluster dev
- Set the dev cluster as the default cluster by adding the config to gke.default in ~/gcloud folder
- Set the dev cluster as the default cluster by adding the config to defaults.json in ~/gcloud folder
- You have a Kubernetes cluster with 1 node-pool. The cluster receives a lot of traffic and needs to grow. You decide to add a node. What should you do?
- Use “gcloud container clusters resize” with the desired number of nodes.
- Use “kubectl container clusters resize” with the desired number of nodes.
- Edit the managed instance group of the cluster and increase the number of VMs by 1.
- Edit the managed instance group of the cluster and enable autoscaling.
- You’re trying to provide temporary access to some files in a Cloud Storage bucket with 20 minutes availability. What is the best way to generate a signed URL?
- Create a service account and JSON key. Use the gsutil signurl -t 20m command and pass in the JSON key and bucket.
- Create a service account and JSON key. Use the gsutil signurl -d 20m command and pass in the JSON key and bucket.
- Create a service account and JSON key. Use the gsutil signurl -p 20m command and pass in the JSON key and bucket.
- Create a service account and JSON key. Use the gsutil signurl -m 20m command and pass in the JSON key and bucket.
Note: The modern equivalent command is gcloud storage sign-url gs://<bucket>/<object> --duration=20m --private-key-file=<key-file>
- You need to deploy a containerized application to Google Cloud with minimal infrastructure management. The application handles variable traffic and you want it to scale to zero when not in use. Which service and command should you use?
- Deploy to GKE Autopilot using gcloud container clusters create-auto and kubectl apply.
- Deploy to Cloud Run using gcloud run deploy <service-name> –image=<image> –region=<region> –allow-unauthenticated.
- Deploy to Compute Engine using gcloud compute instances create-with-container.
- Deploy to App Engine using gcloud app deploy with a Dockerfile.
- Your organization is migrating from gsutil to the new recommended CLI. Which command should you use to upload a local directory to Cloud Storage recursively?
- gsutil cp -r ./data gs://my-bucket/
- gcloud storage objects upload ./data gs://my-bucket/ –recursive
- gcloud storage cp -r ./data gs://my-bucket/
- gcloud storage buckets cp ./data gs://my-bucket/ –recursive
- You need to create a cost-effective VM for a fault-tolerant batch processing workload. Google recommends using Spot VMs instead of preemptible VMs. Which command creates a Spot VM?
- gcloud compute instances create batch-vm –preemptible –max-run-duration=24h
- gcloud compute instances create batch-vm –spot
- gcloud compute instances create batch-vm –provisioning-model=SPOT –instance-termination-action=STOP
- gcloud compute instances create batch-vm –scheduling=spot –maintenance-policy=TERMINATE
- You need to create a fully managed Kubernetes cluster where Google manages the nodes, scaling, and security. Which command should you use?
- gcloud container clusters create my-cluster –enable-autopilot
- gcloud container clusters create-auto my-cluster –region=us-central1
- gcloud container clusters create my-cluster –managed-mode=autopilot
- gcloud container clusters create my-cluster –num-nodes=0 –enable-autoscaling