gcloud command lines for Google Cloud CLI 587.0.0, taken from Google's cheat sheet and from the SYNOPSIS and EXAMPLES sections of the command reference, grouped by task: setup, sign-in, configurations, projects, IAM, Compute Engine, GKE, Cloud Run, Cloud Storage, builds, Cloud SQL and logging. Names such as example-instance or my-bucket are sample values; words in capitals are placeholders. Rows that begin with a dash are flags. Alpha and beta commands and the remaining product groups are left out.
A gcloud command reads left to right as gcloud, an optional release level (alpha or beta), the component, the entity, the operation, then positional arguments and flags.
Command
What it does
gcloud init
Run guided setupInteractive workflow that authorizes an account, picks or creates a configuration and sets its project, region and zone.
gcloud version
Show component versionsLists every installed component with its version number and says when updates exist.
gcloud info
Show environment detailsPrints the active account and project plus the directories where gcloud keeps its logs.
gcloud help -- project
Search the help textFinds commands whose help mentions the words after the double dash; five results unless --limit raises it.
gcloud topic filters
Read the filter syntax guideSupplementary help page on the expressions the --filter flag accepts.
gcloud topic formats
Read the output format guideSupplementary help page on every format name and attribute that --format understands.
gcloud components list
List CLI componentsShows each component's ID and whether it is installed, not installed or has an update waiting.
gcloud components install COMPONENT-1 COMPONENT-2
Install componentsAdds the named components and their dependencies at the CLI version already in use, without upgrading anything.
gcloud components update
Update the CLIBrings every installed component to the newest release after listing the changes and asking for confirmation.
gcloud components remove COMPONENT-1 COMPONENT-2
Remove componentsUninstalls the named components and anything depending on them, after a confirmation prompt.
gcloud feedback
Send feedback to GoogleLists the support channels and opens a browser on the one you pick.
gcloud survey
Open the satisfaction surveyThe recurring survey prompt itself is switched off with the survey/disable_prompts property.
Sign-in and credentials 11
gcloud auth application-default login sets up credentials for client libraries only; it does not change the account that gcloud commands themselves run as.
Command
What it does
gcloud auth login
Sign in with a user accountRuns a web sign-in and makes that account the active one in the current configuration.
gcloud auth login --no-browser
Sign in without a local browserFor a machine with no browser: authorization is finished with the gcloud CLI on a second machine that has one.
gcloud auth list
List credentialed accountsShows every account with stored credentials and marks the single active one.
Set the ADC quota projectRecords which project client libraries use for billing and quota; ADC must already exist.
gcloud auth application-default revoke
Revoke Application Default CredentialsDeletes the local credential file made by application-default login; credentials set up another way are untouched.
Configurations and properties 12
Command
What it does
gcloud config set project PROJECT_ID
Set the default projectStores the project in the active configuration, so later commands target it without --project.
gcloud config set compute/zone ZONE_NAME
Set the default zoneCompute Engine commands then stop prompting for a zone when --zone is left out.
gcloud config set compute/region REGION
Set the default regionRegional Compute Engine commands then no longer ask for a region when --region is omitted.
gcloud config get project
Print one propertyOutputs only the value held by the active configuration.
gcloud config unset project
Clear a propertyRemoves it from the active configuration only, unless --installation is added.
gcloud config list
List active propertiesShows the account, project and default region and zone that the active configuration sets.
gcloud config list --all
List every propertyAlso prints the properties that have no value set.
--installation
Apply to all configurationsFlag of config set and config unset: the change covers the whole installation, not just the active configuration.
gcloud config configurations create my-config
Create a named configurationThe new configuration becomes active straight away unless --no-activate is added.
gcloud config configurations list
List configurations
gcloud config configurations activate my-config
Switch configurationLater commands use that configuration's account, project and other properties.
gcloud config configurations delete my-config
Delete a configurationRefuses the configuration that is active; activate another one first.
Projects, billing and APIs 10
Command
What it does
gcloud projects list
List accessible projectsCovers active projects where the account is Owner, Editor, Browser or Viewer; deleted ones are left out.
gcloud projects describe example-foo-bar-1
Show project metadataFails when the project does not exist or the account has no access to it.
Flatten a list into CSV rowsEach quota of the project becomes one CSV line with its metric, limit and usage.
No row on this page matches that filter.
Notes
The five-minute setup
gcloud auth login runs a web sign-in and makes that account the active one, and gcloud config set project PROJECT_ID stores the project that later commands target. gcloud init walks through both and can also set a default Compute Engine region and zone, and gcloud info prints the active account, project and log paths when something points at the wrong place. For a single command the stored project is overridden with --project=PROJECT_ID.
Flags that change output
--format=FORMAT reshapes the output of any command (json, yaml, a table with chosen columns, a single value), so scripts do not have to parse the default table. --flatten=[KEY,...] turns a list inside a resource into one record per item, which pairs well with a table or CSV format. --quiet, -q disables interactive prompts: defaults are used, or an error is raised when input is required, so it belongs in automation. --flags-file=YAML_FILE loads flags from a YAML or JSON file, which keeps a long deploy command reviewable.
Debugging a command
--log-http writes the underlying HTTP requests and responses to stderr, which shows exactly what a command sent when the error message is opaque. --configuration=CONFIGURATION runs one command with a named configuration without switching the active one. Commands that exist only at the alpha or beta release level are written with that word after gcloud. gcloud help -- project searches the built-in help text for a term, which is often quicker than the web reference.
Questions
How do I switch projects?
gcloud config set project PROJECT_ID changes the default in the active configuration. For one command, add --project=PROJECT_ID.
How do I get JSON from a gcloud command?
Set --format=FORMAT to json, as in gcloud container images list-tags gcr.io/myproject/myimage --format=json. The value format prints a single field, as in gcloud info --format="value(config.account)", which is convenient in shell scripts.
How do I run gcloud in a script without prompts?
Add --quiet, -q (either form). Where input is required the default is used, or an error is raised.
How do I see what API calls a command makes?
Add --log-http. The HTTP requests and responses are written to stderr.
Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.
129 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.
Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.