Shape the future of software delivery and make your voice heard by taking the 2021 State of DevOps survey.

Running gcloud commands with Cloud Shell

Cloud Shell comes with Cloud SDK pre-installed. This means you can run gcloud commands without additional setup. You can run gcloud command-line tool commands, like gcloud help straight away after activating a Cloud Shell session.

Additionally, any time you manage resources using the interactive interface from the Console, you can generate the equivalent gcloud command and run it in Cloud Shell. If you fill in the details of your required resource during tasks like the creation of an instance group or a Kubernetes cluster, the generated command will contain the correct flags and their values.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

Example: Creating a Compute Engine instance with a generated gcloud command

  1. Go to the Compute Engine > VM instances page.
  2. Click Create.
  3. Fill in the required and optional fields to configure the new instance to suit your needs.
  4. Below the Create button, you'll find the option to generate the equivalent REST or gcloud command. Click command line to see the suggested gcloud command. Viewing the equivalent gcloud command for a Compute Engine VM instance creation
  5. Click Run in Cloud Shell.
  6. Press Enter to execute the command once you see it at the prompt.
  7. Going back to the VM instances page, you'll see the newly created and running VM instance.
  8. Delete the instance either from the command line or the VM instances page, if you no longer need it, to avoid incurring unnecessary charges.