Run gcloud commands with Cloud Shell

Learn how to run gcloud CLI commands in Cloud Shell.


To follow step-by-step guidance for this task directly in the Cloud Shell Editor, click Guide me:

Guide me


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 Google Cloud 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 Google Cloud project.

Set gcloud properties

  1. Launch the Cloud Shell Editor.
  2. Prevent color from being used when printing messages to the terminal by setting a core property:

    gcloud config set disable_color true
    
  3. Unset the disable_color property:

    gcloud config unset disable_color
    
  4. If you have the Compute Engine API enabled, set your preferred Compute Engine region. Replace REGION with a region name—for example, us-east1:

    gcloud config set compute/region REGION
    

    Alternatively, you can set your preferred zone. Replace ZONE with a zone name—for example, us-east1-b:

    gcloud config set compute/zone ZONE
    

    For information about Compute Engine regions and zones, see Regions and zones.

  5. Display a list of available properties:

    gcloud topic configurations
    

Run core commands

  1. List accounts whose credentials are stored on the local system:

    gcloud auth list
    

    The gcloud CLI displays a list of credentialed accounts, where ACCOUNT_EMAIL represents a list of one or more active accounts:

    Credentialed Accounts
    ACTIVE  ACCOUNT
    \*      ACCOUNT_EMAIL
    
  2. List the properties in your active gcloud CLI configuration:

    gcloud config list
    

    The gcloud CLI displays the list of properties similar to the following, where ACCOUNT_EMAIL and PROJECT_ID display your email and project ID:

    [core]
    account = ACCOUNT_EMAIL
    disable_usage_reporting = False
    project = PROJECT_ID
    
  3. View information about your gcloud CLI installation and the active configuration:

    gcloud info
    

View help for gcloud commands

  1. View the help for the gcloud compute instances create command:

    gcloud help compute instances create
    
  2. View available commands under gcloud topic:

    gcloud help topic
    
  3. View information on filtering:

    gcloud topic filters
    
  4. Learn more about gcloud command structure:

    gcloud topic command-conventions
    

What's next