Cloud Shell
Cloud Shell is a browser-based terminal pre-authenticated with your project. It comes with the gcloud SDK, git, and other tools pre-installed.
# Check active account
gcloud auth list
# Check current project
gcloud config list projectRegions and zones
A region is a specific geographic location. A zone is an isolated resource within a region.
gcloud config get-value compute/zone
gcloud config get-value compute/region
gcloud compute project-info describe --project <PROJECT_ID>Environment variables
export PROJECT_ID=<your_project_ID>
export ZONE=<your_zone>
echo $PROJECT_ID
echo $ZONECreating a VM
gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone $ZONEKey subcommand: gcloud compute instances create <NAME> — creates a new Compute Engine VM.
SSH into the VM
gcloud compute ssh gcelab2 --zone $ZONEThis auto-generates SSH keys on first connection. Disconnect with exit.
gcloud exploration commands
gcloud -h # Basic help
gcloud config --help # Config-specific help
gcloud config list # Current configuration
gcloud config list --all # All properties
gcloud components list # Installed SDK componentsInstalling the interactive shell
sudo apt-get install google-cloud-sdk
gcloud beta interactiveInteractive mode provides auto-completing prompts with inline help. Exit with exit.