My Docs
BlogGithubLinkedin
Blog-Content
Blog-Content
  • Blog
  • README
    • 10. Regular Expression Matching
    • 13. Roman to Integer
    • 14. Longest Common Prefix
    • 14. Longest Common Prefix
    • 19. Remove Nth Node From End of List
    • 19. Remove Nth Node From End of List
    • 8. String to Integer (atoi)
    • Table of contents
    • All the Things You Can Do With GitHub API and Python
    • Archive
    • Articles
    • Bash Commands That Save Me Time and Frustration
    • Basic Web Development Environment Setup
    • Basic Web Development Environment Setup
    • Blog Archive
    • Blog Archive
    • Blog
    • Bookmarks
    • Cheatsheet:
    • Clock
    • Community
    • Constructor Functions
    • Content
    • Cool Github Profiles
    • Data Structures Interview
    • Docs
    • dynamic-time-warping
    • Embed Showcase
    • Es6 Features
    • Functions
    • Gatsby Paginate
    • Getting Started
    • Google Cloud
    • google-sheets-api
    • History API
    • How to install Python 2.7 on Ubuntu 20.04 LTS
    • HTML SPEC
    • index
    • Installation
    • Installing Node
    • Interactive
    • Intro To NodeJS
    • Intro To React
    • Intro To React
    • Introducing JSX
    • Introduction to npm
    • Javascript and Node
    • Javascript and Node
    • Javascript and Node
    • Javascript Interview Questions:
    • Javascript Interview Questions:
    • Javascript Practice
    • Javascript Practice
    • Javascript Practice
    • JS Fat Arrow Functions
    • Jupyter Notebooks
    • Jupyter Notebooks
    • Leetcode
    • Leetcode
    • Leetcode
    • lorem-ipsum
    • Lorem ipsum
    • Markdown
    • My Favorite VSCode Themes
    • Nature
    • New Conference
    • Node APIs With Express
    • Node APIs With Express
    • Node Buffers
    • Node Docs
    • Node Export Module
    • Node Export Module
    • Node Modules System
    • Node vs Browser
    • Overview
    • Phone Number
    • Process in Linux
    • Pull Requests
    • Python at length
    • Python Quiz
    • Python Quiz
    • Python Snippets
    • Python Snippets
    • React Class Components Demo
    • React Class Components Demo
    • React Docs
    • React In Depth
    • RECENT PROJECTS
    • RECENT PROJECTS
    • Reference
    • Resume
    • Search:
    • Semantic Versioning
    • Showcase
    • Showcase
    • Sorting Algorithms
    • Sorting Strings
    • Starter Theme
    • Starter Theme
    • The Node.js Event Loop
    • The Node.js Event Loop
    • Tools
    • Tools
    • Trouble Shooting
    • Typography
    • UI Components
    • Understanding PATH
    • Understanding PATH
    • URL:
    • Visualizing the Discrete Fourier Transform
    • Web Apis
    • Web Design
    • Web Dev Bookmarks
    • Web Developer Tools
    • What is THIS
    • What is THIS
    • where-is-npm-pack
    • with some basic knowledge of React
    • Zumzi Instant Messenger
Powered by GitBook
On this page
  • The gcloud cheat sheet
  • Cheat sheet
  • Introductory primer
  • Understanding commands

Was this helpful?

Edit on GitHub
  1. README

Google Cloud

PreviousGetting StartedNextgoogle-sheets-api

Last updated 3 years ago

Was this helpful?

The gcloud command-line tool cheat sheet

The gcloud cheat sheet

A roster of go-to gcloud commands for the gcloud tool, Google Cloud's primary command-line tool.

(Also included: , , and a .)

Cheat sheet

Getting started

Get going with the gcloud command-line tool.

  • : Initialize, authorize, and configure the gcloud tool.

  • : Display version and installed components.

  • : Install specific components.

  • : Update your Cloud SDK to the latest version.

  • : Set a default Google Cloud project to work on.

  • : Display current gcloud tool environment details.

Help

Cloud SDK is happy to help.

Personalization

Make the Cloud SDK your own; personalize your configuration with properties.

Credentials

Grant and revoke authorization to Cloud SDK

Projects

Manage project access policies

Identity & Access Management

Configuring Cloud Identity & Access Management (IAM) preferences and service accounts

Docker & Google Kubernetes Engine (GKE)

Manage containerized applications on Kubernetes

Virtual Machines & Compute Engine

Create, run, and manage VMs on Google infrastructure

Serverless & App Engine

Build highly scalable applications on a fully managed serverless platform

Miscellaneous

Commands that might come in handy

Introductory primer

A quick primer for getting started with the gcloud command-line tool.

Installing the Cloud SDK

Flags, arguments, and other wondrous additions

Arguments can be Positional args or Flags

  • Positional args: Set after command name; must respect order of positional args.

  • Flags: Set after positional args; order of flags doesn't matter.

    A flag can be either a:

    • Name-value pair (--foo=bar), or

    • Boolean (--force/no-force).

    Additionally, flags can either be:

    • Required

    • Optional: in which case, the default value is used, if the flag is not defined

Global flags

Some flags are available throughout the gcloud command-line tool experience, like:

Cleaning up results

For Compute Engine instances with prefix us and not machine type f1-micro:

For a list of projects created on or after 15 January 2018, sorted from oldest to newest, presented as a table with project number, project id and creation time columns with dates and times in local timezone:

For a list of ten Compute Engine instances with a label my-label (of any value):

Understanding commands

The underlying patterns for gcloud commands; to aid self-discovery of commands.

Finding gcloud commands

The gcloud command-line tool is a tree; non-leaf nodes are command groups and leaf nodes are commands. (Also, tab completion works for commands and resources!)

Most gcloud commands follow the following format:

For example: gcloud + compute + instances + create + example-instance-1 + --zone=us-central1-a

Release level

Release Level refers to the command's release status.

Example: alpha for alpha commands, beta for beta commands, no release level needed for GA commands.

Component

Component refers to the different Google Cloud services.

Example: compute for Compute Engine, app for App Engine, etc.

Entity

Entity refers to the plural form of an element or collection of elements under a component.

Example: disks, firewalls, images, instances, regions, zones for compute

Operation

Operation refers to the imperative verb form of the operation to be performed on the entity.

Example: Common operations are describe, list, create/update, delete/clear, import, export, copy, remove, add, reset, restart, restore, run, and deploy.

Positional args

Positional args refer to the required, order-specific arguments needed to execute the command.

Example: <INSTANCE_NAMES> is the required positional argument for gcloud compute instances create.

Flags

Flags refer to the additional arguments, --flag-name(=value), passed in to the command after positional args.

Example: --machine-type=<MACHINE_TYPE> and --preemptible are optional flags for gcloud compute instances create.

: Search the gcloud tool reference documents for specific terms.

: Provide feedback for the Cloud SDK team.

: Supplementary help material for non-command topics like accessibility, filtering, and formatting.

: Define a property (like compute/zone) for the current configuration.

: Fetch value of a Cloud SDK property.

: Display all the properties for the current configuration.

: Create a new named configuration.

: Display a list of all available configurations.

: Switch to an existing named configuration.

: Authorize Google Cloud access for the gcloud tool with Google user credentials and set current account as active.

: Like gcloud auth login but with service account credentials.

: List all credentialed accounts.

: Display the current account's access token.

: Remove access credentials for an account.

: Display metadata for a project (including its ID).

: Add an IAM policy binding to a specified project.

: List IAM grantable roles for a resource.

: Create a custom role for a project or org.

: Create a service account for a project.

: Add an IAM policy binding to a service account.

: Replace existing IAM policy binding.

: List a service account's keys.

: Register the gcloud tool as a Docker credential helper.

: Create a cluster to run GKE containers.

: List clusters for running GKE containers.

: Update kubeconfig to get kubectl to use a GKE cluster.

: List tag and digest metadata for a container image.

: List Compute Engine zones.

: Display a VM instance's details.

: List all VM instances in a project.

: Create snapshot of persistent disks.

: Display a snapshot's details.

: Delete a snapshot.

: Connect to a VM instance by using SSH.

: Deploy your app's code and configuration to the App Engine server.

: List all versions of all services deployed to the App Engine server.

: Open the current app in a web browser.

: Create an App Engine app within your current project.

: Display the latest App Engine app logs.

: Decrypt ciphertext (to a plaintext file) using a Cloud Key Management Service (Cloud KMS) key.

: List your project's logs.

: Display info about a Cloud SQL instance backup.

: Export data from a Cloud SQL instance to a SQL file.

Install the Cloud SDK with these .

: For when in doubt; display detailed help for a command.

: If using a project other than the current one.

: Disabling interactive prompting (and applying default values for inputs).

: Can set verbosity levels at debug, info, warning, error, critical, and none.

: Display gcloud version information.

: Set output format as config, csv, default, diff, disable, flattened, get, json, list, multi, none, object, table, text, value, or yaml.

Extricate the most from your output with the , , limit, and sort-by flags.

introductory primer
understanding commands
printable PDF
gcloud init
gcloud version
gcloud components install
gcloud components update
gcloud config set project
gcloud info
gcloud help
gcloud feedback
gcloud topic
gcloud config set
gcloud config get-value
gcloud config list
gcloud config configurations create
gcloud config configurations list
gcloud config configurations activate
gcloud auth login
gcloud auth activate-service-account
gcloud auth list
gcloud auth print-access-token
gcloud auth revoke
gcloud projects describe
gcloud projects add-iam-policy-binding
gcloud iam list-grantable-roles
gcloud iam roles create
gcloud iam service-accounts create
gcloud iam service-accounts add-iam-policy-binding
gcloud iam service-accounts set-iam-policy-binding
gcloud iam service-accounts keys list
gcloud auth configure-docker
gcloud container clusters create
gcloud container clusters list
gcloud container clusters get-credentials
gcloud container images list-tags
gcloud compute zones list
gcloud compute instances describe
gcloud compute instances list
gcloud compute disks snapshot
gcloud compute snapshots describe
gcloud compute snapshots delete
gcloud compute ssh
gcloud app deploy
gcloud app versions list
gcloud app browse
gcloud app create
gcloud app logs read
gcloud kms decrypt
gcloud logging logs list
gcloud sql backups describe
gcloud sql export sql
installation instructions
--help
--project
--quiet
--verbosity
--version
--format
filter
format