Search for a command to run...
Install the Google Cloud CLI 590 on Linux, macOS and Windows, authenticate with IAM, manage configurations and automate Google Cloud with gcloud.
The Google Cloud CLI (gcloud) is the command-line tool for Google Cloud. It manages
resources, configures authentication and installs the companion tools you need.
Google Cloud CLI 590.0.0 · the google-cloud-cli apt and rpm packages ·
Python 3.10 – 3.15 supported · gcloud storage replaces the legacy gsutil ·
components are installed as separate packages when you use apt or rpm
gcloud components install only works with a tarball or Homebrew installation. When you
install with apt or yum, the component manager is disabled and you install
components as packages such as google-cloud-cli-kubectl or
google-cloud-cli-gke-gcloud-auth-plugin instead.
curl, tar and unzip for the manual installation# Install the signing key in a keyring
sudo mkdir -p -m 755 /usr/share/keyrings
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
sudo chmod a+r /usr/share/keyrings/cloud.google.gpg
# Add the Cloud SDK repository
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
| sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Install
sudo apt update
sudo apt install -y google-cloud-cli
# Initialize
gcloud init
# Verify
gcloud --versionapt-key is deprecated and removed on Ubuntu 22.04+ and Debian 12. The command
above writes the key to a keyring and references it with signed-by, which works on
every current distribution.
# Version and components
gcloud --version
# The active configuration
gcloud info
# The projects you can reach
gcloud projects list# Interactive login — opens a browser
gcloud init
# Log in again without re-running init
gcloud auth login
# Use a device code on a headless machine
gcloud auth login --no-launch-browserEvery Google Cloud client library and every tool that talks to the API uses ADC:
# Create the ADC file for local development
gcloud auth application-default login
# Check what ADC currently points at
gcloud auth application-default print-access-token# Create a service account
gcloud iam service-accounts create my-sa \
--display-name "My Service Account"
# Grant it the least privilege it needs
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:my-sa@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/viewer"
# Impersonate it instead of downloading a key
gcloud auth application-default login \
--impersonate-service-account=my-sa@PROJECT_ID.iam.gserviceaccount.comLong-lived JSON keys end up in environment variables, CI logs and repositories. Prefer workload identity federation or service account impersonation — both give short-lived credentials with no key to leak.
A configuration is a named set of properties (account, project, region, zone):
# Create one
gcloud config configurations create my-config
# List them
gcloud config configurations list
# Switch to one
gcloud config configurations activate my-config
# See the active properties
gcloud config list
# Set properties
gcloud config set project PROJECT_ID
gcloud config set compute/region europe-west4
gcloud config set compute/zone europe-west4-a# ~/.config/gcloud/configurations/config_my-config
[core]
account = user@example.com
project = my-project-id
disable_usage_reporting = True
[compute]
zone = europe-west4-a
region = europe-west4# List instances
gcloud compute instances list
# Create an instance
gcloud compute instances create my-instance \
--machine-type=e2-medium \
--image-family=ubuntu-2404-lts-amd64 \
--image-project=ubuntu-os-cloud \
--zone=europe-west4-a
# SSH into it
gcloud compute ssh my-instance --zone=europe-west4-a
# Stop and delete
gcloud compute instances stop my-instance --zone=europe-west4-a
gcloud compute instances delete my-instance --zone=europe-west4-a# Use gcloud storage — gsutil is the legacy tool
gcloud storage buckets create gs://my-bucket --location=EU
# List buckets
gcloud storage ls
# Copy files
gcloud storage cp ./file.txt gs://my-bucket/
gcloud storage rs --recursive ./local-dir gs://my-bucket/dir/
# IAM on a bucket
gcloud storage buckets add-iam-policy-binding gs://my-bucket \
--member="user:john@example.com" \
--role="roles/storage.objectViewer"# Install the auth plugin for GKE (a separate package when installed with apt)
sudo apt install -y google-cloud-cli-gke-gcloud-auth-plugin
# Get the credentials for a cluster
gcloud container clusters get-credentials my-cluster --region=europe-west4
# Then use kubectl
kubectl get nodes# With a tarball or Homebrew installation you can manage components
gcloud components list
gcloud components install kubectl
gcloud components update# With apt or rpm, install the matching package instead
sudo apt install -y google-cloud-cli-kubectl
sudo apt install -y google-cloud-cli-gke-gcloud-auth-plugin
sudo apt install -y google-cloud-cli-docker-credential-gcr# With apt or rpm
sudo apt update && sudo apt install --only-upgrade google-cloud-cli
# With a tarball installation
gcloud components updateroles/viewer and add on.gcloud storage, not the legacy gsutil.--project and --zone explicitly in scripts so the command does not
depend on the active configuration.--format=json and --filter to get machine-readable output.gcloud config set core/disable_usage_reporting true in automation so
non-interactive runs never block on a prompt.Install AWS CLI v2 on Linux, macOS and Windows with the signed install script, authenticate with IAM Identity Center or SSO, and automate AWS from your terminal.
Install Azure CLI 2.91 on Linux, macOS, Windows and Docker, authenticate with device code, service principals and federated credentials, and manage Azure resources from the terminal.