Skip to content

Google Cloud CLI

160 commands

The gcloud CLI for Google Cloud: manage projects, IAM, Compute Engine, GKE and storage from the terminal.

  • GCP
  • cloud
  • IAM

Install Google Cloud CLI

brew install --cask google-cloud-sdk

Basic Setup4

gcloud version

Displays the installed Google Cloud SDK version and component information.

gcloud components list

Lists all available SDK components and their current installation status.

gcloud components update

Updates all installed SDK components to the latest available version.

gcloud help

Displays detailed help documentation for a specific command group or subcommand.

Link

Authentication4

gcloud auth login

Initiates the browser-based authentication flow to log in with a user account.

gcloud auth list

Lists all credentialed accounts currently active in the gcloud environment.

gcloud auth application-default login

Acquires credentials for Application Default Credentials (ADC) used by client libraries.

gcloud auth revoke

Revokes credentials for a specific account, logging them out of the CLI.

Link

Configuration4

gcloud config list

Displays the active configuration properties for the current environment.

gcloud config set project

Sets the default project ID for subsequent commands to target.

Link
gcloud config configurations create

Creates a new named configuration profile to isolate settings between environments.

Link
gcloud config configurations activate

Switches the active CLI context to a specific named configuration.

Link

Project Management3

gcloud projects list

Lists all Google Cloud projects visible to the currently authenticated user.

Link
gcloud projects describe

Shows metadata and lifecycle state for a specific project.

Link
gcloud projects create

Creates a new Google Cloud project with the specified ID and display name.

Link

Identity & Access (IAM)5

gcloud iam roles list

Lists the standard curated IAM roles available in the project.

Link
gcloud iam service-accounts list

Lists all service accounts residing within the current project.

Link
gcloud iam service-accounts create

Creates a new service account within the current project.

Link
gcloud projects get-iam-policy

Retrieves the IAM policy (permissions bindings) attached to the specified project.

Link
gcloud projects add-iam-policy-binding

Adds an IAM policy binding to grant a specific role to a user or principal.

Link

Compute Engine7

gcloud compute zones list

Lists all available Compute Engine zones and their status.

Link
gcloud compute instances list

Lists all virtual machine instances in the project across all zones.

Link
gcloud compute instances describe

Displays detailed configuration and status of a specific VM instance.

Link
gcloud compute instances create

Creates and starts a new VM instance with specified parameters.

Link
gcloud compute instances start

Starts a currently stopped virtual machine instance.

Link
gcloud compute instances stop

Stops a running virtual machine instance.

Link
gcloud compute ssh

Establishes an SSH connection to the instance using automatically managed keys.

Link

Networking5

gcloud compute networks list

Lists all VPC networks defined in the project.

Link
gcloud compute networks subnets list

Lists all subnets associated with VPC networks in the project.

Link
gcloud compute firewall-rules list

Lists all firewall rules configured for the project's networks.

Link
gcloud compute firewall-rules describe

Shows detailed configuration of a specific firewall rule.

Link
gcloud compute firewall-rules create

Creates a new firewall rule allowing incoming TCP traffic on port 80.

Link

Cloud Storage4

gcloud storage ls

Lists all Cloud Storage buckets in the project.

Link
gcloud storage buckets create

Creates a new Cloud Storage bucket.

Link
gcloud storage buckets describe

Displays metadata and settings for a specific bucket.

Link
gcloud storage cp

Copies a file from the local filesystem to a Cloud Storage bucket.

Link

Kubernetes Engine (GKE)2

gcloud container clusters list

Lists all GKE clusters in the project.

Link
gcloud container clusters get-credentials

Configures kubectl to authenticate with the specified GKE cluster.

Link

Cloud Run2

gcloud run services list

Lists all Cloud Run services deployed in the project.

Link
gcloud run services describe

Displays details about a specific Cloud Run service configuration.

Link

Cloud Functions2

gcloud functions list

Lists all Cloud Functions deployed in the project.

Link
gcloud functions deploy

Directly injects Python/Node code bridging it natively into GCP's ecosystem without requiring Dockerfile architectures.

Link

Cloud SQL1

gcloud sql instances list

Lists all Cloud SQL database instances.

Link

Pub/Sub2

gcloud pubsub topics list

Lists all Pub/Sub topics in the project.

Link
gcloud pubsub subscriptions list

Lists all Pub/Sub subscriptions in the project.

Link

Logging2

gcloud logging read

Reads the latest log entries matching a specific filter.

Link
gcloud logging logs list

Lists all log names present in the project.

Link

Output Formatting2

gcloud projects list --format=json

Outputs the list of projects in full JSON format.

Link
gcloud compute instances list --format='table(name, zone, status)'

Displays instance data in a tabular format with specific columns.

Link

Output Filtering2

gcloud compute instances list --filter='status=RUNNING'

Lists only the compute instances that are currently running.

Link
gcloud compute instances list --filter='name:test-*'

Lists instances where the name starts with 'test-'.

Link

Advanced IAM6

gcloud iam service-accounts keys list

Lists the keys associated with a specific service account.

Link
gcloud iam service-accounts keys create

Creates and downloads a new JSON key file for a service account.

Link
gcloud iam roles describe

Shows the permissions included in a specific IAM role.

Link
gcloud iam roles create

Creates a custom IAM role with a defined set of permissions.

Link
gcloud iam workload-identity-pools list

Lists Workload Identity Pools for federated authentication.

Link
gcloud iam workload-identity-pools providers list

Lists identity providers configured within a Workload Identity Pool.

Link

Advanced Compute2

gcloud compute instance-templates list

Lists available instance templates used for creating instance groups.

Link
gcloud compute instance-groups managed list

Lists managed instance groups (MIGs) for autoscaling configurations.

Link

Advanced Networking3

gcloud compute routers list

Lists Cloud Routers used for dynamic routing and NAT.

Link
gcloud compute addresses list

Lists static external and internal IP addresses reserved in the project.

Link
gcloud compute ssl-certificates list

Lists SSL certificates managed by Compute Engine for load balancers.

Link

Security & Audit4

gcloud services list

Lists all APIs and services that are currently enabled in the project.

Link
gcloud services enable

Enables a specific Google Cloud API for the project.

Link
gcloud asset search-all-resources

Searches all resources in the project matching a specific query using Cloud Asset Inventory.

Link
gcloud asset search-all-iam-policies

Finds all IAM policies in the project that grant the Owner role.

Link

Secret Manager2

gcloud secrets list

Lists all secrets stored in Secret Manager.

Link
gcloud secrets versions access

Accesses and prints the payload of the latest version of a secret.

Link

KMS (Key Management)2

gcloud kms keyrings list

Lists all Key Management Service key rings in a specific location.

Link
gcloud kms keys list

Lists cryptographic keys within a specified KMS key ring.

Link

Blue Team Defensive5

gcloud compute firewall-rules list --filter='sourceRanges:(0.0.0.0/0)'

Identifies firewall rules that allow traffic from the entire internet.

Link
gcloud compute instances list --filter='networkInterfaces.accessConfigs.natIP:*'

Lists all VM instances that have an external public IP address assigned.

Link
gcloud projects get-iam-policy my-project --flatten='bindings[].members' --filter='bindings.members:allUsers'

Checks if any project-level IAM policies grant access to 'allUsers' (public access).

Link
gcloud storage buckets list --format='value(name, public_access_prevention)'

Lists buckets and checks their Public Access Prevention status.

Link
gcloud logging sinks list

Lists log router sinks to verify where logs are being exported.

Link

Container Security2

gcloud container clusters list --filter='addonsConfig.kubernetesDashboard.disabled=false'

Checks for GKE clusters that have the legacy Kubernetes Dashboard enabled.

Link
gcloud artifacts repositories list

Lists Artifact Registry repositories to audit container image storage locations.

Link

Automation Workflow4

gcloud compute snapshots list

Lists compute disk snapshots created more than 30 days ago.

Link
gcloud compute disks list

Lists only disks that are currently attached to a VM instance.

Link
gcloud compute disks list --filter='-users:*'

Lists orphaned disks that are not attached to any VM instance.

Link
gcloud builds list

Lists currently running Cloud Build operations.

Link

Advanced Formatting2

gcloud projects list --format='csv(projectId, projectNumber)'

Exports a list of project IDs and numbers to a CSV format.

Link
gcloud iam service-accounts list --format='value(email)'

Extracts and lists only the email addresses of service accounts.

Link

Organization Policy2

gcloud resource-manager org-policies list

Lists organization policies currently applied to the project.

Link
gcloud resource-manager org-policies describe

Describes the configuration of a specific organization policy constraint.

Link

Billing2

gcloud beta billing accounts list

Lists all billing accounts accessible to the user.

Link
gcloud beta billing projects describe

Checks which billing account is linked to a specific project.

Link

Incident Response5

gcloud logging read 'protoPayload.methodName="beta.compute.firewalls.insert"' --limit=5

Searches logs for recent firewall rule creation events.

Link
gcloud logging read 'resource.type="gce_instance" AND protoPayload.methodName="v1.compute.instances.delete"'

Searches logs for VM instance deletion events.

Link
gcloud compute instances add-metadata

Tags a compromised instance with metadata to signal an active investigation.

Link
gcloud compute instances stop --async

Immediately sends a stop signal to a VM without waiting for the operation to complete.

Link
gcloud compute firewall-rules update

Disables a specific firewall rule to immediately cut off access.

Link

Impersonation3

gcloud config set auth/impersonate_service_account

Configures the CLI to impersonate a service account for all subsequent commands.

Link
gcloud config unset auth/impersonate_service_account

Stops service account impersonation and reverts to the original user credentials.

Link
gcloud compute instances list --impersonate-service-account

Runs a single command impersonating a service account without changing global config.

Link

Cloud DNS2

gcloud dns managed-zones list

Lists managed DNS zones in Cloud DNS.

Link
gcloud dns record-sets list

Lists DNS records within a specific managed zone.

Link

App Engine2

gcloud app services list

Lists App Engine services deployed in the standard or flexible environment.

Link
gcloud app versions list

Lists the deployed versions of App Engine services.

Link

BigQuery1

gcloud alpha bq datasets list

Lists BigQuery datasets (note: usually done via 'bq' tool, but gcloud has alpha support).

Link

Deployment Manager1

gcloud deployment-manager deployments list

Lists infrastructure deployments managed by Cloud Deployment Manager.

Link

Advanced Config3

gcloud config set compute/region

Sets the default compute region to avoid specifying the flag in every command.

Link
gcloud config set compute/zone

Sets the default compute zone to avoid specifying the flag in every command.

Link
gcloud config set core/disable_usage_reporting

Disables the anonymous usage reporting sent to Google.

Link

VPC Peering1

gcloud compute networks peerings list

Lists VPC peerings connected to a specific network.

Link

Interconnect1

gcloud compute interconnects list

Lists dedicated physical interconnect connections.

Link

VPN2

gcloud compute vpn-gateways list

Lists Cloud HA VPN gateways.

Link
gcloud compute vpn-tunnels list

Lists VPN tunnels connecting to peer gateways.

Link

Load Balancing3

gcloud compute backend-services list

Lists backend services which process traffic for load balancers.

Link
gcloud compute url-maps list

Lists URL maps used by HTTP(S) load balancers to route requests.

Link
gcloud compute target-http-proxies list

Lists target HTTP proxies used by load balancers.

Link

Filestore1

gcloud filestore instances list

Lists fully managed NFS file servers (Filestore instances).

Link

Memorystore1

gcloud redis instances list

Lists Memorystore for Redis instances.

Link

Cloud Spanner2

gcloud spanner instances list

Lists Cloud Spanner instances.

Link
gcloud spanner databases list

Lists databases within a specific Spanner instance.

Link

Compliance4

gcloud compute project-info describe

Displays project-wide metadata including default network tiers and usage export buckets.

Link
gcloud compute shared-vpc get-host-project

Checks if the current project is attached to a Shared VPC Host project.

Link
gcloud access-context-manager policies list

Lists VPC Service Controls access policies for an organization.

Link
gcloud access-context-manager perimeters list

Lists service perimeters defined in VPC Service Controls.

Link

Advanced Security3

gcloud compute os-login describe-profile

Describes the OS Login profile for the current user, used for SSH access management.

Link
gcloud alpha scc assets list

Lists assets monitored by Security Command Center (SCC).

Link
gcloud alpha scc findings list

Lists active security findings detected by Security Command Center.

Link

Cloud Scheduler2

gcloud scheduler jobs list

Lists scheduled cron jobs.

Link
gcloud scheduler jobs run

Forces a Cloud Scheduler job to run immediately.

Link

Cloud Tasks1

gcloud tasks queues list

Lists queues used for asynchronous task execution.

Link

Dataproc1

gcloud dataproc clusters list

Lists Hadoop/Spark clusters managed by Dataproc.

Link

Dataflow1

gcloud dataflow jobs list

Lists Dataflow streaming and batch jobs.

Link

Operations Suite2

gcloud monitoring dashboards list

Lists custom monitoring dashboards created in Cloud Monitoring.

Link
gcloud monitoring policies list

Lists alerting policies defined in Cloud Monitoring.

Link

Identity Aware Proxy (IAP)1

gcloud compute start-iap-tunnel

Starts an IAP tunnel to forward a local port to the instance's SSH port.

Link

Advanced Storage3

gcloud storage buckets update

Updates a bucket to enforce uniform bucket-level access (disabling object ACLs).

Link
gcloud storage objects update

Modifies object ACLs (caution: creates public objects).

Link
gcloud storage hmac list

Lists HMAC keys used for S3-interoperable storage access.

Link

Service Directory1

gcloud service-directory namespaces list

Lists namespaces in Service Directory.

Link

Recaptcha Enterprise1

gcloud recaptcha keys list

Lists reCAPTCHA Enterprise keys.

Link

Health Checks1

gcloud compute health-checks list

Lists health checks used by load balancers and managed instance groups.

Link

Instance Groups1

gcloud compute instance-groups unmanaged list

Lists unmanaged instance groups (often used for legacy setups).

Link

Complex Filtering2

gcloud compute instances list --filter='tags.items:web-server AND machineType:e2-micro'

Filters instances that have the 'web-server' network tag AND are e2-micro.

Link
gcloud projects list --filter='createTime < 2023-01-01'

Filters projects created before a specific date.

Link

Cleanup7

gcloud compute instances delete

Deletes a VM instance without interactive confirmation.

Link
gcloud storage rm

Deletes a specific object from a Cloud Storage bucket.

Link
gcloud storage rm -r

Recursively deletes a bucket and all objects contained within it.

Link
gcloud projects delete

Shuts down a project and schedules it for deletion.

Link
gcloud compute firewall-rules delete

Deletes a specific firewall rule.

Link
gcloud container clusters delete

Deletes a GKE cluster and its associated resources.

Link
gcloud iam service-accounts delete

Deletes a service account identity.

Link

Endpoints1

gcloud endpoints services list

Lists Cloud Endpoints services.

Link

Source Repositories2

gcloud source repos list

Lists Cloud Source Repositories hosted in the project.

Link
gcloud source repos clone

Leverages internal encrypted GCP authentication schemas to clone inherently private VPC-locked Git repositories.

Link

Policy Troubleshooting1

gcloud policy-intelligence troubleshoot

Troubleshoots why a principal has or lacks a specific permission on a resource.

Link

Cloud Shell1

gcloud alpha cloud-shell ssh

Connects to the interactive Cloud Shell environment via SSH.

Link

Feedback1

gcloud feedback

Submits feedback about the gcloud CLI to the Google team.

Link

Cloud Run (Serverless Conatiners)2

gcloud run deploy

Instantly compiles a standard Docker container straight into a fully load-balanced, auto-scaling web application.

Link
gcloud run services list

Maps all live auto-scaling container configurations, resolving direct HTTPs public invocation endpoints.

Link

Pub/Sub Messaging2

gcloud pubsub topics create

Establishes a highly decoupled message ingestion point capable of receiving millions of asynchronous API payloads.

Link
gcloud pubsub subscriptions pull

Manually interrogates a subscription queue, extracting pending messages natively and systematically acknowledging them via CLI.

Link

Spanner (Global Database)1

gcloud spanner instances list

Inventories globally distributed strictly-consistent NoSQL relational nodes detailing structural allocation.

Link

Cloud Build (CI/CD)1

gcloud builds submit

Uploads the entire localized CWD to Google's build arrays, executing the Docker build remotely to circumvent local compute limitations.

Link

IAM Service Accounts1

gcloud iam service-accounts keys create

Extracts absolute God-Mode local authentication architectures bypassing MFA to programmatically impersonate cloud environments.

Link

Artifact Registry1

gcloud artifacts docker tags add

Manipulates strictly-defined OCI metadata remapping canonical latest pointers onto explicitly secured hash versions.

Link