LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

gcloud

Google Cloud Platform command-line interface

TLDR

Initialize gcloud and set up configuration
$ gcloud init
copy
Login to Google Cloud
$ gcloud auth login
copy
Set the active project
$ gcloud config set project [project-id]
copy
List all projects
$ gcloud projects list
copy
Create a Compute Engine VM instance
$ gcloud compute instances create [name] --zone=[zone]
copy
List running VM instances
$ gcloud compute instances list
copy
Get application-default credentials for local development
$ gcloud auth application-default login
copy
Format output as JSON for scripting
$ gcloud compute instances list --format=json
copy

SYNOPSIS

gcloud group [command] [options]

DESCRIPTION

gcloud is the Google Cloud Platform CLI for managing cloud resources. It provides commands for all GCP services including Compute Engine, Kubernetes Engine, Cloud SQL, Cloud Run, Cloud Functions, and more.
The tool handles authentication, configuration, and resource management. Commands are organized by service groups with subcommands for specific operations. The --format and --filter flags are essential for scripting and automation.
Multiple named configurations can be managed with gcloud config configurations for switching between projects and accounts.

PARAMETERS

GROUP

Service group: compute, container, iam, sql, storage, functions, run, etc.
auth
Authentication and credential commands.
config
Configuration management.
compute
Compute Engine commands.
container
Kubernetes Engine commands.
projects
Project management.
--project ID
Override the default project for this command.
--format FORMAT
Output format: json, yaml, csv, table, text, value, etc.
--filter EXPRESSION
Filter results (e.g. 'name~prod').
--quiet, -q
Disable interactive prompts and use defaults.
--verbosity LEVEL
Logging verbosity: debug, info, warning, error, critical, none.
--help
Display help information.

CONFIGURATION

~/.config/gcloud/configurations/config_default

Default configuration properties including project, region, zone, and account settings.
~/.config/gcloud/credentials.db
Encrypted credentials database for authenticated accounts.
~/.config/gcloud/properties
User-specific gcloud properties and preferences.

CAVEATS

Requires a GCP account and project. Actions may incur costs. Some commands need specific IAM permissions. The gcloud CLI is part of the Google Cloud SDK, which must be installed separately from most package managers.

HISTORY

gcloud is part of the Google Cloud SDK, first released in 2013 as the primary CLI for Google Cloud Platform administration and automation. It has grown to cover hundreds of GCP services and is continuously updated with new features.

SEE ALSO

gsutil(1), kubectl(1), bq(1)

Copied to clipboard
Kai