Tool cheatsheet
Google Cloud CLI (gcloud) Cheatsheet
Sign in and manage projects, Compute Engine, Cloud Run, storage, Kubernetes, logs and secrets with gcloud.
Setup and configuration
- Check the CLI version — Print the gcloud version and installed components.
- Initialize gcloud — Sign in and choose a default project and region interactively.
- Sign in — Sign in with your Google account in the browser.
- Set up application default credentials — Create credentials that client libraries and tools on your machine use.
- Set the default project — Make a project the default for later commands.
- Show current settings — Print the active account, project and region.
- List projects — Show the projects you can access.
- Create a named configuration — Switch between accounts and projects with named configurations.
- Update gcloud — Update the CLI and its installed components.
- Enable an API — Turn on a Google Cloud API for the project.
Compute Engine
- List VM instances — Show the VMs in the project.
- Create a VM — Create a small Debian VM in a zone.
- Connect to a VM with SSH — SSH into an instance. gcloud manages the keys.
- Stop a VM — Stop an instance. You stop paying for compute but not for its disks.
- Delete a VM — Delete a VM instance permanently.
- Copy a file to a VM — Copy a local file to an instance.
- Allow traffic to a port — Create a firewall rule that allows HTTPS from anywhere.
Cloud Run, Functions and builds
- Deploy to Cloud Run from source — Build the current folder and deploy it as a Cloud Run service.
- Deploy a container image to Cloud Run — Deploy an existing image.
- Read Cloud Run logs — Print recent logs of a service.
- Show a service's URL — Print the URL of a deployed service.
- Deploy a function — Deploy an HTTP-triggered Python function from the current folder.
- Build an image with Cloud Build — Build and push a container image to Artifact Registry.
Storage, secrets and logs
- List buckets or objects — List buckets, or objects in a bucket.
- Copy files to or from a bucket — Copy a local file to a bucket. Add --recursive for folders.
- Sync a folder with a bucket — Make a bucket match a local folder.
- Read a secret — Print the latest version of a Secret Manager secret.
- Store a secret — Create a secret from a file.
- Read logs — Query the most recent error log entries.
- List Cloud SQL instances — Show the Cloud SQL databases in the project.
Kubernetes and IAM
- Connect kubectl to GKE — Add a cluster's credentials to your kubeconfig.
- List GKE clusters — Show the Kubernetes clusters in the project.
- List service accounts — Show the service accounts in the project.
- Grant a role — Give a user a role on the project.
- Authenticate Docker to Artifact Registry — Let Docker push and pull images from a registry host.
Output and filtering
- Choose the output format — Print results as JSON. Other formats include yaml, table and value.
- Capture a single value — Print a bare field, suited to scripts.
- Filter resources — Filter results on the server side.
- Skip confirmation prompts — Accept defaults without asking, as scripts need.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.