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 tool commands, like gcloud help, immediately after activating a Cloud Shell session.

Additionally, any time you manage resources using the interactive interface from the Cloud 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 contains 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.

  4. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

Creating a Compute Engine instance with a generated gcloud command

To use a generated Compute Engine VM instance creation gcloud command, follow these steps:

  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. After you see the command at the prompt, press Enter to run the command.
  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.

Interactive tutorial

To further explore the gcloud command-line tool, you can try out a couple of core gcloud commands in Cloud Shell with the following interactive tutorial:

Open in Cloud Shell