[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eThe Google Cloud CLI's \u003ccode\u003egcloud compute\u003c/code\u003e command group lets you manage Compute Engine resources, and is an alternative to using the Compute Engine API.\u003c/p\u003e\n"],["\u003cp\u003eYou can set a default project for \u003ccode\u003egcloud compute\u003c/code\u003e commands, either during Google Cloud CLI initialization or by using the \u003ccode\u003e--project\u003c/code\u003e flag or \u003ccode\u003eCLOUDSDK_CORE_PROJECT\u003c/code\u003e environment variable.\u003c/p\u003e\n"],["\u003cp\u003eDefault region and zone can be set in the metadata server, local client, or environment variables, with environment variables having the highest precedence, and can be viewed using the \u003ccode\u003egcloud config get-value\u003c/code\u003e commands.\u003c/p\u003e\n"],["\u003cp\u003eYou can override default settings by using flags like \u003ccode\u003e--region\u003c/code\u003e and \u003ccode\u003e--zone\u003c/code\u003e when running \u003ccode\u003egcloud compute\u003c/code\u003e commands.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egcloud topic configurations\u003c/code\u003e is an advanced feature that lets you influence the behavior of the gcloud CLI, and is useful for those with multiple projects or accounts.\u003c/p\u003e\n"]]],[],null,["Linux Windows\n\n*** ** * ** ***\n\nThe Google Cloud CLI lets you manage your Compute Engine resources, using the\n`gcloud compute` command group. `gcloud compute` is an alternative to using the\nCompute Engine API.\n\nThe gcloud CLI is part of the [Google Cloud CLI](/sdk) and is a unified\ncommand-line tool that includes features like statement autocompletion,\nin-place updating, command-line help, human-readable and\nmachine-parsable output formats, and integration with Google Cloud CLI.\n| **Note:** Looking for reference pages for `gcloud compute` commands? Try the command-line `--help` function. For example, to get help about instance creation, use `gcloud compute instances create --help`. You can see all command-line documentation at [Google Cloud CLI reference](/sdk/gcloud/reference/compute).\n\nIf you have never used Compute Engine, get started with either the\n[Linux quickstart](https://cloud.google.com/compute/docs/create-linux-vm-instance) or\nthe [Windows quickstart](/compute/docs/create-windows-server-vm-instance).\n\nBefore you begin\n\n- If you want to run `gcloud compute` in a command prompt, [install,\n update, and initialize the Google Cloud CLI](/sdk/docs/install-sdk).\n- If you don't have a command prompt readily available, try using `gcloud compute` in [Cloud Shell](/shell/docs). Cloud Shell is automatically installed, updated, and initialized with the latest Google Cloud CLI.\n\nDefault properties\n\nWhen you create a virtual machine instance, Compute Engine configures a VM\nusing default properties from the\n[metadata server](/compute/docs/storing-retrieving-metadata#default). You can\ncheck your VM's default properties by running the following command: \n\n```\ngcloud compute project-info describe --project PROJECT_ID\n```\n\nReplace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID.\n\nDefault project\n\nIf you set a default project when you setup and initialize the Google Cloud CLI,\nall `gcloud compute` commands use that project ID by default.\n\nYou can override the default project ID by using either of the following methods:\n\n- Run each `gcloud compute` command with the `--project` flag\n- Set the `CLOUDSDK_CORE_PROJECT` environment variable\n\n Linux and macOS\n\n Use the `export` command to set the project environment variable. \n\n ```\n export CLOUDSDK_CORE_PROJECT=PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the project ID of the project\n that you want to use as default.\n\n **Unsetting project environment variables**\n\n If you need to unset your project environment variables, use the following\n `unset` commands: \n\n ```\n unset CLOUDSDK_CORE_PROJECT\n ```\n\n Windows\n\n Use the `set` command to set the project environment variable. \n\n ```\n set CLOUDSDK_CORE_PROJECT=PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the project ID of the project\n that you want to use as default.\n\n **Unsetting project environment variables**\n\n If you need to unset your project environment variables, use the following\n command: \n\n ```\n set CLOUDSDK_CORE_PROJECT=\n ```\n\nIf you do not set a default project or environment variable, you must include a\n`--project` flag in each `gcloud compute` command that you run.\n\nDefault region and zone\n\nSome `gcloud compute` commands require `--region` or `--zone` flags.\nInstead of specifying these flags each time you run commands, you can set a\ndefault region and zone for your project. If you don't set a default region or\nzone and you run a region- or zone-dependent command, the Google Cloud CLI might\nprompt you to provide a `--region` or `--zone` flag, or return an error.\n\nYou can set the default region and zone in three ways:\n\n- [**In the metadata server**](#set-default-region-zone-metadata). The default region and zone set in the metadata server are applied to your local client when you run `gcloud init`.\n- [**In your local client**](#set_default_zone_and_region_in_your_local_client). The default region and zone set in your local client override the default region and zone set in the metadata server.\n- [**In environment variables**](#set-default-region-zone-environment-variables). The default region and zone set in environment variables override the default region and zone set in your local client and in the metadata server.\n\nYou can [override the default region and zone](#override_default) in the\nmetadata server, in your local client, or in environment variables, by providing\n`--region` and `--zone` flags when you run commands.\n\nView default region and zone\n\nTo view your default region and zone, run the following\ncommands: \n\n```\ngcloud config get-value compute/region\n``` \n\n```\ngcloud config get-value compute/zone\n```\n\nIf the output is `(unset)`, no default region or zone is set.\n\nView available regions and zones\n\nYou can view a list of regions and zones by running the following commands: \n\n```\ngcloud compute regions list\n``` \n\n```\ngcloud compute zones list\n```\n\nSet default region and zone in the metadata server\n\nThe default region and zone in the metadata server apply to all\n[configurations](#configurations) in your project. To set the default region and\nzone in the metadata server, do the following:\n\n1. Set the default region and zone:\n\n ```\n gcloud compute project-info add-metadata \\\n --metadata google-compute-default-region=REGION,google-compute-default-zone=ZONE\n ```\n\n For example: \n\n ```\n gcloud compute project-info add-metadata \\\n --metadata google-compute-default-region=europe-west1,google-compute-default-zone=europe-west1-b\n ```\n2. Initialize the change in your local client:\n\n ```\n gcloud init\n ```\n\nYou can override the default region and zone set in the metadata server by\nsetting the default region and zone in your local client, setting the default\nregion and zone in environment variables, or by including the `--zone` or\n`--region` flag in your commands.\n| **Note:** There are no restrictions on which zone or regions you can set for your default properties. For example, it is possible to set a default zone outside of the default region.\n\nUnset default region and zone in the metadata server\n\nTo unset the default region and zone in the metadata server, do the following:\n\n1. Unset metadata:\n\n ```\n gcloud compute project-info remove-metadata \\\n --keys=google-compute-default-region,google-compute-default-zone\n ```\n2. Initialize the change in your local client:\n\n ```\n gcloud init\n ```\n\nSet default region and zone in your local client\n\nThe default region and zone set in your local client override the default\nregion and zone set in the metadata server.\n\nTo set the default region and zone in your local client, run the following\ncommands: \n\n```\ngcloud config set compute/region REGION\n``` \n\n```\ngcloud config set compute/zone ZONE\n```\n\nUnset default region and zone in your local client\n\nTo unset the default region or zone in your local client, run the following\ncommands: \n\n```\ngcloud config unset compute/zone\n``` \n\n```\ngcloud config unset compute/region\n```\n\nYou can override the default region and zone set in your local client by setting\nthe default region and zone in environment variables, or by including the\n`--zone` or `--region` flag in your commands.\n\nSet default region and zone in environment variables\n\nThe default region and zone set in environment variables override the default\nregion and zone set in your local client and in the metadata server. \n\nLinux and macOS\n\nUse the `export` command to set the region and zone variables. \n\n```\nexport CLOUDSDK_COMPUTE_REGION=REGION\n``` \n\n```\nexport CLOUDSDK_COMPUTE_ZONE=ZONE\n```\n\nTo make these environment variables permanent, include these commands in\nyour `~/.bashrc` file and restart your terminal.\n\nWindows\n\nUse the `set` command to set the region and zone variables. \n\n```\nset CLOUDSDK_COMPUTE_REGION=REGION\n``` \n\n```\nset CLOUDSDK_COMPUTE_ZONE=ZONE\n```\n\nYou can override environment variables by including the `--zone` or `--region`\nflag in your commands.\n\nUnset default region and zone in environment variables\n\nUse the following commands to unset the default region and zone in environment\nvariables. \n\nLinux and macOS\n\nTo unset your region and zone environment variables, use the following\n`unset` commands: \n\n```\nunset CLOUDSDK_COMPUTE_REGION\n``` \n\n```\nunset CLOUDSDK_COMPUTE_ZONE\n```\n\nWindows\n\nTo unset your region and zone environment variables, use the following\ncommands: \n\n```\nset CLOUDSDK_COMPUTE_REGION=\n``` \n\n```\nset CLOUDSDK_COMPUTE_ZONE=\n```\n\nOverride default zone with flags\n\nUse the `--zone` flag to override the default zone\nset in the metadata server, your local client, and environment variables.\n\nFor example: \n\n```\ngcloud compute instances create example-instance \\\n --zone=ZONE\n```\n\nConfigurations\n\n[`gcloud topic configurations`](/sdk/gcloud/reference/topic/configurations) are\nan advanced feature that you can use to influence the behavior of the\ngcloud CLI. For most users, using default configurations is\nsufficient.\n\nConfigurations might be useful for users who:\n\n- Work with multiple projects. You can create a separate configuration for each project.\n- Use multiple accounts. For example, a user account and a service account.\n- Perform a variety of independent tasks (work on an App Engine app in one project, administer a Compute Engine cluster in zone us-central-1a, manage the network configurations for region asia-east-1, etc.)\n\nTo switch between configurations, run the following command: \n\n```\ngcloud config configurations activate CONFIGURATION_NAME\n```\n\nFor more information about managing configurations, see\n[`gcloud config configurations`](/sdk/gcloud/reference/config/configurations).\n\nWhat's next?\n\n- Follow the [Quickstart](/sdk/docs/quickstarts) guide for the Google Cloud CLI.\n- Review `gcloud compute` [usage tips](/compute/docs/gcloud-compute/tips).\n- Discover [common `gcloud compute` commands](/compute/docs/gcloud-compute/common-commands)."]]