Learn how to install, configure, and use the gcloud CLI to manage Google Cloud resources directly from your terminal.
When working with Google Cloud, the gcloud CLI is one of the most powerful tools at your disposal. Instead of navigating the Cloud Console UI, you can manage resources, configure services, and automate tasks, all from your terminal.
Whether you’re a beginner exploring Google Cloud for the first time or a developer looking to speed up your workflow, the gcloud CLI offers a consistent and scriptable way to interact with your projects. In this guide, we’ll cover installation, setup, and the basic commands you need to get started.
The gcloud CLI is Google Cloud’s official command-line interface. It lets you interact with almost every Google Cloud service including Compute Engine, Kubernetes Engine, Cloud Storage, and BigQuery.
With gcloud, you can:
Think of it as your Swiss Army knife for Google Cloud.
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-darwin-arm.tar.gz
tar -xf google-cloud-cli-darwin-arm.tar.gz
./google-cloud-sdk/install.shOr simply use Homebrew (macOS):
brew install --cask gcloud-cliDownload the installer from Google Cloud SDK and follow the wizard.
After installation, verify with:
gcloud --versionRun the init command:
gcloud initThis will:
To check active project:
gcloud config listHere are some essentials you’ll use often:
# List VM instances
gcloud compute instances list
# Create a VM
gcloud compute instances create my-vm --zone=us-central1-a# List buckets
gcloud storage buckets list
# Upload a file
gcloud storage cp file.txt gs://my-bucket/# Add a role to a user
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="user:example@gmail.com" \
--role="roles/viewer"If you work with multiple projects:
gcloud config configurations create dev
gcloud config configurations create prodSwitch between them easily:
gcloud config configurations activate prodSince it’s CLI-based, you can script your workflows:
#!/bin/bash
# Deploy VM + storage bucket
gcloud compute instances create demo-vm --zone=us-east1-b
gcloud storage buckets create gs://demo-bucketAdd this to CI/CD pipelines for repeatable deployments.
Use --help to explore commands:
gcloud compute --helpAlways check your active project to avoid creating resources in the wrong one.
Use tab completion for faster command discovery.
The gcloud CLI may feel intimidating at first, but once you get the hang of it, you’ll wonder how you ever managed Google Cloud without it. It’s faster, more scriptable, and perfect for automating repetitive tasks.
Start small. List VMs, create a storage bucket, and gradually move into scripting and multi-project management. The more you practice, the more natural it will feel.
Liked this post? Stay tuned for my upcoming deep-dive on automating Google Cloud deployments with gcloud and Terraform!
Coming soon.