Skip to main content
Welcome back. In this hands-on lesson we’ll practice using the gcloud CLI from Cloud Shell. You may have used gcloud before (for example, when working with IAM). Here we’ll run several common commands and cover practical defaults, authentication, and interacting with resources like Compute Engine and Cloud Storage. gcloud has many commands — you don’t need to memorize them all. Google maintains a comprehensive gcloud CLI cheat sheet you can search as needed. Quick reference: common gcloud commands
Cloud Shell gives you a browser-based shell with the gcloud SDK preinstalled, so you don’t need to install anything locally. It is free to use with reasonable limits for development, but sessions are ephemeral — your home directory is persisted, but VM instances are temporary and idle sessions may be terminated.
Getting started with Cloud Shell
  1. In the GCP Console click the Cloud Shell (terminal) button. The first start can take longer while the environment gets provisioned.
  2. When Cloud Shell is ready you can run gcloud commands directly.
A sample Cloud Shell welcome looks like this:
Verify the gcloud SDK is installed and view the version:
View current gcloud configuration
Set default project, zone, and region
  • Set the default project:
  • Set a default Compute Engine zone (example: us-central1-a):
  • Set a default region (example: us-central1):
Authenticate the gcloud CLI
  • Inside Cloud Shell you are usually already authenticated.
  • From a local machine or other environment run:
This opens a browser to sign in and prompts you to paste a verification code back into the terminal. Example interactive session:
List projects you have access to
Sample output:
Note: you will only see projects for which your account has permission. Organization-level visibility and access depend on your IAM roles. Interacting with Cloud Storage Cloud Storage is comparable to Amazon S3. Common Storage commands:
  • List buckets in the current project:
  • List objects in a specific bucket:
Can you build an entire infrastructure using gcloud? Yes. The gcloud CLI can create service accounts, VPC networks and subnets, firewall rules, Compute Engine instances, GKE clusters, and more. In a follow-up demo we’ll use gcloud to create an end-to-end set of resources from the command line. Links and references That’s it for this lesson — see you in the next one.

Watch Video